how to get item from ListView how to get item from ListView sqlite sqlite

how to get item from ListView


Instead of TextView clickData=(TextView) view;, write this:

TextView clickData=(TextView) view.findViewById(R.id.textView5);

This is because onItemClick receives the whole itemView, and the parent in your itemView is a RelativeLayout, which cannot be cast to a TextView. You need to find the TextView within the parent itemView.


Not sure if i understand your question correctly but i assume you would like to get your data as a String, rather than a TextView (the latter does not really make sense).

@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {    Cursor cursor = (Cursor) simpleCursorAdapter.getItem(position);    String data = cursor.getString(0); // replace 0 with the desired column index    Toast.makeText(getBaseContext(), data, Toast.LENGTH_LONG).show();}


Use this:

TextView tv =(TextView) ((ViewGroup) view.getChildAt(0));