i have a custom listview that fill from database and i want when click on any item value of textview pass to another activity, how should i do? please help me!
this is all code , thanks u source code: Edit:
public class ListActivity extends Activity {
String value = "";
MovieDB myDbHelper;
SQLiteDatabase db;
ListAdapter adapter;
ArrayList<HashMap<String, String>> data;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_layout);
final ListView lst=(ListView) findViewById(R.id.listView1);
Load_Database();
db = myDbHelper.getReadableDatabase();
Cursor c = db.rawQuery("select * from movie_list where product = '"+value+"' Or name like '%"+value+"%'" , null);
data = new ArrayList<HashMap<String, String>>();
for (; c.moveToNext();) {
HashMap<String, String> map = new HashMap<String, String>();
String img = c.getString(c.getColumnIndex("img"));
String name = c.getString(c.getColumnIndex("name"));
map.put("img", img);
map.put("name", name);
data.add(map);
}
adapter = new ListMovie(this, data);
lst.setAdapter(adapter);
lst.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
final Intent GoToDisplay = new Intent(ListActivity.this,DisplayActivity.class);
GoToDisplay.putExtra("position", data.get(arg2));
startActivity(GoToDisplay);
}
});
}
private void Load_Database() throws Error {
myDbHelper = new MovieDB(ListActivity.this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
} catch (SQLException sqle) {
throw sqle;
}
}
}