Add:
lv.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id)
{
// In the following line "v" refers to the View returned by the `getView()` method; meaning the clicked View.
TextView txtName = (TextView)v.findViewById(R.id.yourTextViewID);
String name = txtName.getText().toString();
switch(name)
{
case "nameOne":
Intent intent = new Intent(YourCurrentActivity.this, NameOneActivity.class);
startActivity(intent);
break;
case "nameTwo":
Intent intent = new Intent(YourCurrentActivity.this, NameTwoActivity.class);
startActivity(intent);
break;
//And so on and so forth....
}
}
});
after
lv.setAdapter(custom);
.
Of course, replace YourCurrentActivity
and YourNextActivity
with the corresponding names.
Intents
are used to start up other activities.
You can also use intent.putExtra("extraValue", theValue);
to pass variable values from one activity to another.
More information about Intents
here.