我希望在点击它时在toast中显示值项目。怎么办?
public class MainActivity extends ActionBarActivity implements Callback {
ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BDDRequest.GetRequest(this, SendData.getUserTest(), this);
mListView = (ListView) findViewById(R.id.listrequest);
}
@Override
public void onSuccess(String response) {
List<String> myList = new ArrayList<String>(Arrays.asList(response.split("comClient")));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, myList);
mListView.setAdapter(adapter);
}
@Override
public void onError() {
//Show fallback message here
}
}
答案 0 :(得分:0)
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), mylist.get(position), Toast.LENGTH_LONG).show();
}
})