AndroidManifest.xml 中设置 主Active
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" package="com.example.game_01_listview" android:versionCode="1" android:versionName="1.0" ><uses-sdk
android:minSdkVersion="7" android:targetSdkVersion="17" /><application
android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.game_01_listview.AndroidBasicsStarter" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
AndroidBasicsStarter.java 实现ListActive绑定并LogCat输出
import android.app.ListActivity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ListView;import android.util.Log;public class AndroidBasicsStarter extends ListActivity { String tests[] = { "LifeCycleTest", "SingleTouchTest", "MultiTouchTest", "KeyTest", "AccelerometerTest", "AssetsTest", "ExternalStorageTest", "SoundPoolTest", "MediaPlayerTest", "FullScreenTest", "WakeLockTest", "RenderViewTest", "ShapeTest", "BitmapTest", "FontTest", "SurfaceViewTest" };public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, tests)); }@Override
protected void onListItemClick(ListView list, View view, int position, long id) { super.onListItemClick(list, view, position, id); String testName = tests[position]; Log.i(testName,testName); }}