Removing muliple items from listview using Check box in Android

Use a SparseBooleanArray to get the checked items and then delete the same and refresh listview. public class MainActivity extends Activity { ListView lv; ArrayAdapter<String> adapter; Button delete; ArrayList<String> data = new ArrayList<String>(); SparseBooleanArray mCheckStates ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test); lv = (ListView)findViewById(R.id.listView1); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); delete = (Button)findViewById(R.id.button1); data.add(“Windows”); data.add(“Android”); data.add(“Apple”); data.add(“Blackberry”); … Read more

Android Studio Project: bottom of UI is cut off

This is because you are using CoordinatorLayout with ListView. You can change your implementation to RecyclerView to achieve correct scroll. or If you are tagetting above 5.0, you can use the following piece of code if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { listView.setNestedScrollingEnabled(true); } I think CoordinatorLayout only works with the children of NestedScrollingChild.

Access Fragment in Activity?

You could do the following with Otto event bus: public class UpdateListEvent { private int fragmentState; public UpdateListEvent(int fragmentState) { this.fragmentState = fragmentState; } } public class MainActivity extends ActionBarActivity { … public void updatelist() { SingletonBus.INSTANCE.getBus().post(new UpdateListEvent(fragmentState)); } } public class FragmentA extends Fragment { @Override public void onResume() { super.onResume(); SingletonBus.INSTANCE.getBus().register(this); } @Override … Read more

how to set choice mode single for listview with images

The recommended solution here is to rely on built-in ListView’s selection support specifying single-choice mode for it: list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); Then you should let your list item to implement to implement Checkable interface; that requires some customization of the root view of your layout. Assuming that it has LinearLayout as a root, an implementation may look like: … Read more