2

我必须在功能开始之前提供之前的所有链接,如果我点击其中的项目ListView,它必须转到那个视频链接,现在我给出了持有人中的链接ListView,如果我点击第一个项目,它看起来不太好在ListView,它将采用我需要的相应方式的第一个链接。

 @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;
                    final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(((Recipedetails1) o).getUrlWiki()));
                      startActivity(i);
} 
            });
        }

        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;
        }

实际上我不需要这种方式,因为它看起来不太好,我希望我的链接不显示,它必须在单击 ListView 中的项目后工作,实际上在我的代码中,单击项目后它会去,但是它将从我的持有人链接中获取这是提供链接的任何其他方式。这种代码方法看起来不太好,我不需要我的持有人也想显示我的链接

4

2 回答 2

2

现在我的代码正在运行,我在我的列表适配器中删除了 url wiki 的持有者,现在它看起来很好并且工作正常,我评论这一行 //holder.recipeLinkWiki.setText(itemDetailsrrayList1.get(position).getUrlWiki());

于 2013-03-11T05:58:18.627 回答
1

您可以image_details通过单击位置从数组列表中获取链接。image_details.get(position).getUrlWiki();

像这样使用它:

ArrayList<Recipedetails1> image_details;

@Override
        public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main1);

        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) { 
                //int pos = lv1.getItemAtPosition(position);
                String link = image_details.get(position).getUrlWiki();
                final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
                  startActivity(i);


} 


 });
    }
于 2013-03-11T05:17:41.470 回答