Java 获取OnClickListener中的数组位置

Java 获取OnClickListener中的数组位置,java,android,arrays,Java,Android,Arrays,我试图使用bundle将递增的mPath[]值传递给我的新意图。但我不知道如何增加它 for (int i=0; i<jsonArray.length(); i++) { String path_name = jsonArray.getJSONArray(i).getString(3); Toast.makeText(MainActivity.this, path_name, Toast.LENGTH_LONG).show(); mPath[i] =

我试图使用bundle将递增的
mPath[]
值传递给我的新意图。但我不知道如何增加它

for (int i=0; i<jsonArray.length(); i++)
{        
    String path_name = jsonArray.getJSONArray(i).getString(3);
    Toast.makeText(MainActivity.this, path_name, Toast.LENGTH_LONG).show();
    mPath[i] = "http://www.mywebsite.com/tattoo/" + path_name;        
}

list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, mStrings, mImages);
list.setAdapter(adapter);

list.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){

        Bundle bundle = new Bundle();
        bundle.putString("selection", mPath[INCREMENT]);

        Intent myIntent = new Intent(MainActivity.this, ShowFullSize.class);
        myIntent.putExtras(bundle);
        startActivityForResult(myIntent, 0); 
    }
});

for(int i=0;i如果mstrings/mImages大小与mPath相同,则可以传递第三个参数值,即index/position

bundle.putString("selection", mPath[arg2]);

为什么不利用listview中项的位置并根据需要增加数组的值呢

 `list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, mStrings, mImages);
list.setAdapter(adapter);

list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){

    Bundle bundle = new Bundle();
//instead of INCREMENT here use arg2 which gives you the position of the list item clciked.
    bundle.putString("selection", mPath[arg2]);

    Intent myIntent = new Intent(MainActivity.this, ShowFullSize.class);
    myIntent.putExtras(bundle);
    startActivityForResult(myIntent, 0); 
}
});
`list=(ListView)findViewById(R.id.list);
适配器=新的LazyAdapter(此、mStrings、mImages);
list.setAdapter(适配器);
list.setOnItemClickListener(新的OnItemClickListener(){
公共视图单击(AdapterView arg0、视图arg1、整型arg2、长型arg3){
Bundle=新Bundle();
//这里使用arg2代替增量,arg2给出了列表项clciked的位置。
bundle.putString(“选择”,mPath[arg2]);
Intent myIntent=新Intent(MainActivity.this、ShowFullSize.class);
myIntent.putExtras(bundle);
startActivityForResult(myIntent,0);
}
});
`

bundle.putString("selection", mPath[arg2]);
 `list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, mStrings, mImages);
list.setAdapter(adapter);

list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){

    Bundle bundle = new Bundle();
//instead of INCREMENT here use arg2 which gives you the position of the list item clciked.
    bundle.putString("selection", mPath[arg2]);

    Intent myIntent = new Intent(MainActivity.this, ShowFullSize.class);
    myIntent.putExtras(bundle);
    startActivityForResult(myIntent, 0); 
}
});