当数组中有空格时如何打开新意图(例如“Hello World”)我试图访问的类称为startingPoint。
它给了我一个错误,因为 -> android:name="" 中不能有任何空格
有什么解决方法吗?
提前致谢
根.java
public class Root extends ListActivity {
String classes[] = { "Hello World", "Another Item", "Email"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Root.this,
R.layout.root, classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String MENU_CHOICE = classes[position];
try {
Class ourClass = Class.forName("se.hello.visboken." + MENU_CHOICE);
Intent ourIntent = new Intent(Root.this, ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
我的清单看起来像这样
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Root"
android:label="@string/app_name">
<intent-filter>
<action android:name="se.hello.visboken.ROOT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".startingPoint"
android:label="Hello World" >
<intent-filter>
<action android:name="se.hello.visboken.startingPoint" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>