android - 如何在 WishProductDetails.java 中显示点击的产品信息

标签 android android-listview

例如:我们在购物车应用程序中看到,当用户选择某些商品并在最后阶段他/她想要更改商品的数量时,这里我们允许用户点击 ListView 中的商品来更新项目的数量,一旦用户点击 ListView 中的项目,我们就会向他/她显示已被点击的项目的现有详细信息......以同样的方式,我希望允许用户点击项目并想要向他显示其商品的现有详细信息...只想显示用户在 WishProductDetails.java 中点击的现有产品信息

我仍然能够显示 WishProductDetails.java,但无法在 Activity 中显示点击的项目详细信息..

我使用下面的代码来显示 WishProductDetails.java 中的现有项目详细信息,我已使用 ListView 项目行在购物车 Activity 中单击了该详细信息...

        HashMap<String, String> item = Constant.wishProducts.get(position);
        Log.d("CartAdapter", "onClick :: " + item);
        Intent myIntent = new Intent 
        (activity, WishProductDetails.class);
        Log.d("CartAdapter", "Intent :: " + myIntent);
        myIntent.putExtra("Item", item);
        activity.startActivity(myIntent);  

与将商品添加到购物车并接受商品数量相关的工作,我正在做的所有此类工作WishProductDetails.java

现在我希望每当用户单击任何 ListView 项目行时,我都需要在 WishProductDetails.java Activity 中显示该特定项目以及现有详细信息。

最佳答案

我猜测您正在使用 ImageButton 从购物车中删除商品,我从未从事过此类项目,但我正在写我的想法,例如:

 mImgBtnDelete = (ImageButton) vi
            .findViewById(R.id.mImgBtnDelete);
    mImgBtnDelete.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            Constant.wishproducts.remove(position);
            notifyDataSetChanged();
}

编辑#2

Code to Update an Item using on ListView Item Row

我认为在您的 Adapter 类中,您应该添加如下代码,以在单击项目行时更新项目的数量,但非常坦率地说,我不知道如何在 WishProductDetail.java 中打开该特定项目(其中您允许用户输入数量)

  public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.cart, null);
        vi.setClickable(true);
        vi.setFocusable(true);
        vi.setOnClickListener(new OnClickListener() {


  @Override
        public void onClick(View v) 
        {
            HashMap<String, String> prod = Constant.wishproducts.get(position);
        Intent mViewCartIntent = new Intent
                (activity,ProductInformationActivity.class);             
        mViewCartIntent.putExtra("product", prod);
        activity.startActivity(mViewCartIntent);           
        }
    });

关于android - 如何在 WishProductDetails.java 中显示点击的产品信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16116503/

相关文章:

android - 如何允许另一个应用程序访问我的应用程序的数据目录?

安卓初学者 : Touch events in android gridview

android - 为什么图像旋转动画只能在第一次正常工作

android - 在 Android 中从 sqlite 创建 Json

java - 如何通过 ListView 传递数据,Android - Java

android - 调用 stopService 方法时服务不会停止

android - 在提供包含的不仅仅是 TextView 的组 View 时,如何保留 ExpandableListView 的默认列表项按下行为?

android - 自定义 ListView,其中所有图像都具有相同的大小

android - 不幸的是应用程序已停止,doinbackground() 出错

android - JSON 解析成 ListView