我有一个活动,我想用它来在我的列表视图中打开意图,但是当它用作活动名称时,使用 StrawberryShake 在我的列表视图中看起来不太好有没有办法重命名为 android 中的活动名称添加空间以便在列表视图中它看起来像
示例 A
示例 B
示例 C
而不是
示例A
示例B
示例C
这是我的代码
// 列表中的示例项 static final String[] breakfood = { "Strawberry_Shake", };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, breakfood));
// Setting up the list array above
}
// Setting the onlick listener so the array will open up activity
protected void onListItemClick(ListView lv, View v, int position, long id){
super.onListItemClick(lv, v, position, id);
String openbreakclass = breakfood[position];
try{
// Using the class name to open up the activity from the previous array but its
//displaying the dash in the list
Class selected = Class.forName("com.example.yummini."+ openbreakclass);
Intent selectedIntent = new Intent(this, selected);
startActivity(selectedIntent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}