2013-04-20 38 views
2

像我们在购物车应用程序中看到的,当用户选择一些项目并且在最后阶段他/她想要改变项目的数量时,点击列表视图中的项目来更新项目的数量,并且一旦用户点击列表视图中的项目,我们向他/她显示已被点击的项目的现有细节....以我想要的相同方式允许用户敲击项目,要显示他现有的详细信息,他项....只是想表明现有的已经在WishProductDetails.java如何在WishProductDetails.java中显示抽头产品信息

仍然被窃听用户,我能够显示WishProductDetails产品信息.java但无法在活动中显示“抽头项目详细信息”..

我使用下面的代码显示现有WishProductDetails.java项目细节我一直在使用列表视图项排在点击车活动...

 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的活动,特别是项目现有的细节。

+0

在常量类中有一个函数删除。使用索引可以从列表中删除一个项目。在适配器上更新listview调用notifyDataSetChanged()中的相同内容。 – Raghunandan 2013-04-20 04:19:18

回答

3

我猜测你使用的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 

我想在你的适配器类,你应该添加代码类似下面,更新项目的数量,同时点击项目列,但很坦诚,我不知道如何打开该特定项目在WishPro中ductDetail.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);   
     } 
    }); 
+0

感谢您的帮助,如果可能请告诉我如何使用ListView项目行更新产品详细信息,如果我允许用​​户在WishProductDetails.java中输入项目的数量... – 2013-04-20 04:37:37

+0

好的..我会尝试它,然后让你知道 – Android 2013-04-20 04:39:01

+0

再次感谢您的支持,但我想知道如何更新该特定项目,我点击了列表视图项目行 – 2013-04-20 04:54:09

相关问题