package com.example.app;
import com.example.app.adaptor.*;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
public class ListviewExample extends ListActivity {
static final String[] ASDFGH = new String[] { "ABC", "PQR",
"XYZ", "RAA","AA" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new etcArray(this, main_activity ));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// get selected items
String selectedValue = (String) getListAdapter().getItem(position);
if(selectedValue.equalsIgnoreCase("ABC"))
{
Intent in = new Intent(getApplicationContext(),ABC.class);
startActivity(in);
}
else
if(selectedValue.equalsIgnoreCase("AA"))
{
Intent in = new Intent(getApplicationContext(),AA.class);
startActivity(in);
}
}
在上面的程序中......使用像 if string.equalsIgnorecase("AA") 这样的正常条件,我们可以在特定点击上启动意图!是否有任何方法可以在任何列表视图项目单击中启动活动???