我对android非常陌生,我做了一个listview。但是当您单击列表中的任何项目时,我无法弄清楚如何使列表视图可点击并打开一个新活动。如果在得到任何帮助之前回答了这个问题,我很抱歉。我的代码:
public class MainActivity extends Activity {
private ListView mainListView ;
private ArrayAdapter<String> listAdapter ;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainListView = (ListView) findViewById( R.id.mainListView );
String[] converters = new String[] { "1", "2", "3", "4",
"5", "6", "7", "8"};
ArrayList<String> itemsList = new ArrayList<String>();
itemsList.addAll( Arrays.asList(converters) );
listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, itemsList);
listAdapter.add( "9" );
listAdapter.add( "10" );
listAdapter.add( "11" );
listAdapter.add( "12" );
listAdapter.add( "13" );
mainListView.setAdapter( listAdapter );
}
}