I have make a checkbox in each check it call a function
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkbox = (CheckBox) findViewById(R.id.checkBox1);
ListView mainListView = mDrawerList;
checkbox = (CheckBox) mainListView.getChildAt(0);
checkbox = (CheckBox) mainListView.getChildAt(1);
checkbox = (CheckBox) mainListView.getChildAt(2);
checkbox = (CheckBox) mainListView.getChildAt(3);
for (int x = 0; x < mainListView.getChildCount(); x++) {
if (checkbox.isChecked()) {
getMain();
}
else if (checkbox1.isChecked()) {
second();
}
else if (checkbox2.isChecked()) {
third();
}
else if (checkbox3.isChecked()) {
forth();
} else {
getMain();
}
}
}
});
This is my DrawlerList.xml
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@id/checkBox1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/list_item_title"
android:gravity="center_vertical"
android:paddingRight="40dp"/>
And in string.xml i set my items name
<string-array name="nav_drawer_items">
<item>Home</item>
<item>Second</item>
<item>Third</item>
<item>Forth</item>
</string-array>
But when i clicking only one checkbox but it displaying all function alertbox also
What I have tried:
When i try to call only one function
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMain(); // Now only one alert box is there
}
});