我也有一个带有图像和链接功能的列表视图,现在我需要的是我想在列表视图中的每个项目中创建一个按钮,如果我单击按钮它必须进行另一个活动,在该活动页面中它必须单击按钮分别打开一个xml文件,我将预先在列表视图java文件中硬编码xml文件的详细信息,如何做到这一点。
public class SouthIndianvegrecipes extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
ArrayList<Recipedetails1> image_details = GetSearchResults();
final ListView lv1 = (ListView) findViewById(R.id.listV1_main);
lv1.setAdapter(new ItemListBaseAdapter1(this, image_details));
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv1.getItemAtPosition(position);
Recipedetails1 obj_itemDetails = (Recipedetails1)o;
Toast.makeText(SouthIndianvegrecipes.this, "You have chosen : " + " " + obj_itemDetails.getName1(), Toast.LENGTH_LONG).show();
}
});
}
private ArrayList<Recipedetails1> GetSearchResults(){
ArrayList<Recipedetails1> results = new ArrayList<Recipedetails1>();
Recipedetails1 item_details = new Recipedetails1();
item_details.setName1("Vegterian");
item_details.setItemDescription1("Recipes made by raw materials");
item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU");
item_details.setImageNumber1(1);
results.add(item_details);
item_details = new Recipedetails1();
item_details.setName1("Non-Vegterian");
item_details.setItemDescription1("Flesh of sweet animals");
item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU");
item_details.setImageNumber1(2);
results.add(item_details);
item_details = new Recipedetails1();
item_details.setName1("Pickels");
item_details.setItemDescription1("Touchable dish by Homemade");
item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU");
item_details.setImageNumber1(3);
results.add(item_details);
item_details = new Recipedetails1();
item_details.setName1("Soups");
item_details.setItemDescription1("Startup for our food");
item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU");
item_details.setImageNumber1(4);
results.add(item_details);
return results;
}
}