Hiding the checkedtextview flag

im using checktextview in listview.i to display olly textview when d list view is first loaded. When I click the button, I want to populate the list view with different data and should also show a checkbox. (im failed to hide the checked text box check box initially) .plz help me

+4
source share
3 answers

I would just use a custom adapter that will return a TextView or CheckedTextView depending on whether you clicked the button.

You can also try making checkedTextView.setCheckMarkDrawable(null);

+6
source
 <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:checkMark="@null"/> 
0
source

This question is old, but it may help someone in the future.

Step 1

create a boolean variable in onCreate to make the if|else|while method easier (to be used in step 3)

  boolean changedData = true; 

Step 2

I want to display text in text mode when d list view is first loaded

Just leave your code as it is, assuming it looks like

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_1, yourData); listView.setAdapter(adapter); 

Step 3

when I click the button, I want to fill out the list view with different data and which should also show a checkbox

just create a new button this way

  populateBtn.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { if (changedData == true) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_multiple_choice, differentData); listView.setAdapter(adapter); changedData = false; }else if (changedData == false) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_1, yourData); listView.setAdapter(adapter); changedData = true; } }); } 

Thus, the first time you click the button, you get a ListView with CheckBox with the new data

And after clicking the button again, it will return to ListView without CheckBox with old data

If you want to make CheckBox available just read the answer from this link.

A simple list item element that does not select items

0
source

Source: https://habr.com/ru/post/1347237/


All Articles