我从某个地方获得了这段代码并进行了编辑。你能告诉我如何从起始项中删除那些单选按钮吗?我正在获取所有列表项右侧的单选按钮。我不希望那样......没有XML文件。
package com.example.diseasedetection;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.Toast;
public class Desc extends ListActivity {String[] trekloc =
{"VIEW INFO","","PLEASE SELECT THE DISEASE","MALARIA","CONJUNCTIVITIS","MIGRANE"
};
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getListView().setChoiceMode(1);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice, trekloc));
}
public void onListItemClick(ListView parent, View v, int position, long id)
{
Toast.makeText(this, trekloc[position] + " selected ", Toast.LENGTH_SHORT).show();
Intent i = new Intent("com.example.diseasedetection.Dispdesc");
Bundle extras = new Bundle();
extras.putString("Name", trekloc[position]);
i.putExtras(extras);
startActivity(i);
}
}
答案 0 :(得分:0)
而不是
android.R.layout.simple_list_item_single_choice
使用
android.R.layout.simple_list_item_1
答案 1 :(得分:0)
删除getListView()。setChoiceMode(1);
替换android.R.layout.simple_list_item_single_choice
与
android.R.layout.simple_list_item_1。