String[] price ={
"RM9.50",
"RM6.50",
"RM10.80",
"RM80.20",
"RM100.60",
"RM50.10",
"RM12.30",
"RM90.50"
};
String[] itemname ={
"Safari",
"Camera",
"Global",
"FireFox",
"UC Browser",
"Android Folder",
"VLC Player",
"Cold War"
};
Integer[] imgid={
R.drawable.pic1,
R.drawable.pic2,
R.drawable.pic3,
R.drawable.pic4,
R.drawable.pic5,
R.drawable.pic6,
R.drawable.pic7,
R.drawable.pic8,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
inputSearch = (EditText) findViewById(R.id.inputSearch);
CustomListAdapter adapter=new CustomListAdapter(this, itemname, imgid, price);
list=(ListView)findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
String Slecteditem = itemname[+position];
Toast.makeText(getApplicationContext(), Slecteditem, Toast.LENGTH_SHORT).show();
}
});
} //main actiivty
这是主函数调用的自定义列表适配器。代码显示了所有项目的列表。但是,我想点击其中一个列表项以显示包含更多详细说明的新页面。第一张图显示了列表视图,第二张图是更详细的描述。
public CustomListAdapter(Activity context, String[] itemname, Integer[] imgid, String[] price) {
super(context, R.layout.mylist, itemname);
// TODO Auto-generated constructor stub
this.context=context;
this.itemname=itemname;
this.imgid=imgid;
this.price=price;
}
public View getView(int position,View view,ViewGroup parent) {
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.mylist, null,true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);
txtTitle.setText(itemname[position]);
imageView.setImageResource(imgid[position]);
extratxt.setText(price[position]);
return rowView;
};
}
答案 0 :(得分:0)
您可以覆盖onListItemClick方法并启动一个新类。您也可以使用putExtra()将数据传递给新的Activity
if(isset($_GET['page']))
{
$page = $_GET['page'];
echo $page;
//your code
}