如何通过从所选项目的数据在ListView到另一个活动?目的、选项、数据、ListView

2023-09-07 11:34:15 作者:输给时间

我有以下的code。我有0 的对象中的数据。有在三组值0 (描述,名称,图像URL)。我需要这些数据被初始化为字符串,并使用它的意图传递给其他活动。如何获取对象中的每个值。每个列表项目都有一个形象,项目名称和项目描述。

  fp_list.setOnItemSelectedListener(新OnItemSelectedListener(){    @覆盖    公共无效onItemSelected(适配器视图parentView,视图V,INT位置,长的id){        // TODO自动生成方法存根        Toast.makeText(getApplicationContext(),POS+位置,Toast.LENGTH_LONG).show();        对象o = parentView.getItemAtPosition(位置);        意图I =新意图(FeaturedProductsActivity.this,ShowProduct.class);    }} 

解决方案

 捆绑包=新包();                bundle.putString(memId,o.getId());                意图newIntent =新意图(friendsOffrinends.this,RestaurantDetails.class);                newIntent.putExtras(包);                startActivityForResult(newIntent,0); 

C 怎么把textbox上的数据在listview上显示

I have the following code. I have the data in the object o. There are three set of values in o (description, name, image url). I need these data to be initialized to a string and pass it to other activity using intent. How do I get each value in the object. Each list item has a image, item name and item description.

fp_list.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView parentView, View v, int position, long id) {
        // TODO Auto-generated method stub
        Toast.makeText(getApplicationContext(), "pos"+position, Toast.LENGTH_LONG).show();
        Object o = parentView.getItemAtPosition(position);
        Intent i = new Intent(FeaturedProductsActivity.this, ShowProduct.class);
    }
}

解决方案

      Bundle bundle =new Bundle();

                bundle.putString("memId",o.getId() );
                Intent newIntent=new Intent(friendsOffrinends.this,RestaurantDetails.class);
                newIntent.putExtras(bundle);
                startActivityForResult(newIntent, 0);

 
精彩推荐
图片推荐