I have a Custom List View. Each row of the list view contains a checkbox, 2 text views and an image view. I have been tring to open another activity on click of any row of the list view but the onItemClick is not working at all.
public class SavedAddress2 extends AppCompatActivity implements AdapterView.OnItemClickListener {
private Toolbar toolbar;
private ListView listView1;
List<list_addr> rowitems;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.saved_address2);
toolbar = (Toolbar) findViewById(R.id.tool_bar3);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
rowitems = new ArrayList<list_addr>();
listView1 = (ListView) findViewById(R.id.addr_list);
list_addr_adapter adapter = new list_addr_adapter(this,
R.layout.items_sav_addr2, SavedAddress.rowitems);
listView1.setAdapter(adapter);
listView1.setOnItemClickListener(this);
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(Main.this,Second.class);
startActivity(intent);
}
//...
}
Is it because I have a checkbox in the list? Because I have applied the same method for other list view and they work perfectly.
Try seting your checkbox not focusable, like this:
android:focusable="false"
android:focusableInTouchMode="false"
Hope it helps.