将gridview所选项目位置传递给ViewFipper android

将gridview所选项目位置传递给ViewFipper android,android,gridview,viewflipper,Android,Gridview,Viewflipper,我正在GridView中显示来自web服务的图像。当用户在GridView中选择项目时,它会打开ViewsLipper,以更大的分辨率显示相同的图像(通过另一个链接从web服务获得) 问题在于,当用户在GridView中选择第三项时,会打开带有列表项的ViewFlipper(而不是第三项) 如何传递所选项目的位置 GridViewActivity.java grid_view.setOnItemClickListener(new OnItemClickListener() {

我正在
GridView
中显示来自web服务的图像。当用户在
GridView
中选择项目时,它会打开ViewsLipper,以更大的分辨率显示相同的图像(通过另一个链接从web服务获得)

问题在于,当用户在
GridView
中选择第三项时,会打开带有列表项的ViewFlipper(而不是第三项)

如何传递所选项目的位置

GridViewActivity.java

grid_view.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // TODO Auto-generated method stub

                TextView txt_product_name=(TextView)view.findViewById(R.id.txt_prod_name);
                String product_name=txt_product_name.getText().toString();

                TextView txt_product_path=(TextView)view.findViewById(R.id.txt_prod_fetch_name);
                String product_path=txt_product_path.getText().toString();

                TextView txt_product_id=(TextView)view.findViewById(R.id.txt_prod_id);
                String product_id=txt_product_id.getText().toString();

                TextView txt_product_details=(TextView)view.findViewById(R.id.txt_prod_details);
                String product_details=txt_product_details.getText().toString();



                Intent intent=new Intent(GetInspiredProducts.this,ViewFlipperActivity.class);
                intent.putExtra("product_name", product_name);
                intent.putExtra("product_path", product_path);

                intent.putExtra("product_id", product_id);
                intent.putExtra("product_details", product_details);

                intent.putExtra("cat_id", cat_id);
                startActivity(intent);

            }
        });
protected List doInBackground(String... params) {
        // TODO Auto-generated method stub
        if (NetworkCheck.isNetworkAvailable(GetInspiredProductDetail.this)==true) {


            try{
                jsonObj=userFunctions.getInspiredProducts(cat_id);
                Log.e("getInspiredCategory", "kargetinsp "+jsonObj);


                JSONArray json_array=jsonObj.getJSONArray("posts");

                for (int i = 0; i < json_array.length(); i++) 
                {
                    JSONObject json_obj=json_array.getJSONObject(i);
                    String category=json_obj.getString("post");


                    JSONObject json_obj_=new JSONObject(category);

                    String picture_path=json_obj_.getString("PicturePath");
                    String picture_name=json_obj_.getString("PictureName");
                    String picture_id=json_obj_.getString("PictureId");
                    String picture_details=json_obj_.getString("PictureDetails");


                    HashMap<String, String> hash_map=new HashMap<String, String>();
                    hash_map.put("flipper_image",AllLinks.PRODUCTS_LARGE_IMAGE_URI+picture_path);
                    hash_map.put("flipper_name",picture_name);
                    hash_map.put("flipper_path",picture_path);
                    category_hash_map.add(hash_map);


                    Log.e("VIEW_FLIPPER1", "karjeev "+picture_path);

                    /*HashMap<String, String> hash_map=new HashMap<String, String>();
                    hash_map.put("products_pic_path",  AllLinks.PRODUCTS_THUMB_PICTURE_PATH+picture_path);
                    hash_map.put("products_pic_name", picture_name);
                    category_hash_map.add(hash_map);    */

                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }

        }
grid_view.setOnItemClickListener(新的OnItemClickListener(){
@凌驾
public void onItemClick(AdapterView父级、视图、,
内部位置,长id){
//TODO自动生成的方法存根
TextView txt_product_name=(TextView)view.findViewById(R.id.txt_prod_name);
字符串product_name=txt_product_name.getText().toString();
TextView txt\u product\u path=(TextView)view.findViewById(R.id.txt\u prod\u fetch\u name);
字符串product_path=txt_product_path.getText().toString();
TextView txt_product_id=(TextView)view.findviewbyd(R.id.txt_prod_id);
字符串product_id=txt_product_id.getText().toString();
TextView txt_product_details=(TextView)view.findviewbyd(R.id.txt_prod_details);
字符串product_details=txt_product_details.getText().toString();
意向意向=新意向(GetInspiredProducts.this,ViewFlipperActivity.class);
意向。putExtra(“产品名称”,产品名称);
intent.putExtra(“产品路径”,产品路径);
意图。putExtra(“产品标识”,产品标识);
意向。额外(“产品详细信息”,产品详细信息);
意图。putExtra(“cat_id”,cat_id);
星触觉(意向);
}
});
ViewFlipperActivity.java

grid_view.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // TODO Auto-generated method stub

                TextView txt_product_name=(TextView)view.findViewById(R.id.txt_prod_name);
                String product_name=txt_product_name.getText().toString();

                TextView txt_product_path=(TextView)view.findViewById(R.id.txt_prod_fetch_name);
                String product_path=txt_product_path.getText().toString();

                TextView txt_product_id=(TextView)view.findViewById(R.id.txt_prod_id);
                String product_id=txt_product_id.getText().toString();

                TextView txt_product_details=(TextView)view.findViewById(R.id.txt_prod_details);
                String product_details=txt_product_details.getText().toString();



                Intent intent=new Intent(GetInspiredProducts.this,ViewFlipperActivity.class);
                intent.putExtra("product_name", product_name);
                intent.putExtra("product_path", product_path);

                intent.putExtra("product_id", product_id);
                intent.putExtra("product_details", product_details);

                intent.putExtra("cat_id", cat_id);
                startActivity(intent);

            }
        });
protected List doInBackground(String... params) {
        // TODO Auto-generated method stub
        if (NetworkCheck.isNetworkAvailable(GetInspiredProductDetail.this)==true) {


            try{
                jsonObj=userFunctions.getInspiredProducts(cat_id);
                Log.e("getInspiredCategory", "kargetinsp "+jsonObj);


                JSONArray json_array=jsonObj.getJSONArray("posts");

                for (int i = 0; i < json_array.length(); i++) 
                {
                    JSONObject json_obj=json_array.getJSONObject(i);
                    String category=json_obj.getString("post");


                    JSONObject json_obj_=new JSONObject(category);

                    String picture_path=json_obj_.getString("PicturePath");
                    String picture_name=json_obj_.getString("PictureName");
                    String picture_id=json_obj_.getString("PictureId");
                    String picture_details=json_obj_.getString("PictureDetails");


                    HashMap<String, String> hash_map=new HashMap<String, String>();
                    hash_map.put("flipper_image",AllLinks.PRODUCTS_LARGE_IMAGE_URI+picture_path);
                    hash_map.put("flipper_name",picture_name);
                    hash_map.put("flipper_path",picture_path);
                    category_hash_map.add(hash_map);


                    Log.e("VIEW_FLIPPER1", "karjeev "+picture_path);

                    /*HashMap<String, String> hash_map=new HashMap<String, String>();
                    hash_map.put("products_pic_path",  AllLinks.PRODUCTS_THUMB_PICTURE_PATH+picture_path);
                    hash_map.put("products_pic_name", picture_name);
                    category_hash_map.add(hash_map);    */

                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }

        }
protectedlist doInBackground(字符串…参数){
//TODO自动生成的方法存根
if(NetworkCheck.isNetworkAvailable(GetInspiredProductDetail.this)==true){
试一试{
jsonObj=userFunctions.getInspiredProducts(cat_id);
Log.e(“getInspiredCategory”、“kargetinsp”+jsonObj);
JSONArray json_array=jsonObj.getJSONArray(“posts”);
for(int i=0;i
ViewFlipperAdapter.java

public Object instantiateItem(View container, int position) {

        HashMap<String, String> song = new HashMap<String, String>();
        song = data.get(position);

        View view = mInflater.inflate(R.layout.demo_page_copy, null);
        ((ViewPager) container).addView(view, 0);



        ImageView img = (ImageView) view.findViewById(R.id.list_image);
        TextView txtName = (TextView) view.findViewById(R.id.txt_prod_det);
        final TextView txtPath = (TextView) view.findViewById(R.id.txt_prod_path);

        imageLoader.DisplayImage(song.get("flipper_image"),img);
        txtName.setText(song.get("flipper_name"));
        txtPath.setText(song.get("flipper_path"));

        view.setContentDescription(content);
        view.setOnClickListener(new OnClickListener() {

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

                String path=txtPath.getText().toString();

                Log.d("image path", String.valueOf(v.getContentDescription()));
                Intent intent=new Intent(context,ImageZoom.class);
                intent.putExtra("image", AllLinks.PRODUCTS_LARGE_IMAGE_URI+path);           
                context.startActivity(intent);

            }
        });



        return view;
    }
public对象实例化项(视图容器,int位置){
HashMap宋=新HashMap();
宋=数据。获取(位置);
视图=mInflater.flate(R.layout.demo\u page\u copy,null);
((ViewPager)容器).addView(视图,0);
ImageView img=(ImageView)view.findViewById(R.id.list\u image);
TextView txtName=(TextView)view.findViewById(R.id.txt\u prod\u det);
final TextView txtPath=(TextView)view.findViewById(R.id.txt\u prod\u path);
imageLoader.DisplayImage(song.get(“flipper\u image”)、img;
txtName.setText(song.get(“flipper_name”);
setText(song.get(“flipper_path”);
view.setContentDescription(内容);
view.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
字符串路径=txtPath.getText().toString();
Log.d(“图像路径”,String.valueOf(v.getContentDescription());
意向意向=新意向(上下文,ImageZoom.class);
intent.putExtra(“image”,AllLinks.PRODUCTS\u LARGE\u image\u URI+path);
背景。开始触觉(意图);
}
});
返回视图;
}

您是如何为view Flipper下载图像的?该web服务的参数是什么。我猜您发送了错误的参数。我使用了:--用于GridView(拇指图像)和:--用于ViewFlipper(大图像)你的问题是“大图像”是错误的,对吗?我无法打开你的链接。这不是问题。检索大图像需要什么输入。你检查了吗?例如图像id之类的东西&我将整个图像传递给GridView,将整个图像传递给ViewFlipper。不知道如何将选定的图像位置传递给Viewfl伊珀