次のコードでは、pwd を onclick イベントに渡す方法
String pwd ="/root";
final ListView lv = (ListView) findViewById(R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng)
Toast.makeText(MainActivity.this,pwd , Toast.LENGTH_SHORT).show();
}
編集1:
final String pwd = null;
string pwd ="root"; //Error remove final keyword
final ListView lv = (ListView) findViewById(R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng)
Toast.makeText(MainActivity.this,pwd , Toast.LENGTH_SHORT).show();
}