현재 코드 내에서 어댑터를 이용하여 4개의 콜럼을 가진 리스트뷰를 사용하고 있습니다. 여기에서 아이템을 클릭했을 때 클릭된 아이템의 일부 콜럼만 조회하고픈데 어떤 방법이 있을까요??
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.city_list);
db = new DBHelper(this);
list = (ListView)findViewById(R.id.city_list);
db.getListContents();
final ArrayList<InfoClass> weatherList = new ArrayList<InfoClass>();
Cursor data = db.getListContents();
if(data.getCount() == 0){
Toast.makeText(this, "There are no contents in this list!",Toast.LENGTH_LONG).show();
}else{
while(data.moveToNext()){
InfoClass newInfo = new InfoClass(data.getString(1), data.getString(2), data.getString(3), data.getString(4));
weatherList.add(newInfo);
DBAdapter dbAdapter = new DBAdapter(this, weatherList);
list.setAdapter(dbAdapter);
}
}
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
/* TextView item_latitude = (TextView)findViewById(R.id.item_latitude);
TextView item_longitude = (TextView)findViewById(R.id.item_longitude);
data_longitude = item_latitude.getText().toString();
data_latitude = item_longitude.getText().toString();*/
Intent intent = new Intent(CityList.this, MainActivity.class);
intent.putExtra("data_latitude", data_latitude);
intent.putExtra("data_longitude", data_longitude);
setResult(Activity.RESULT_OK, intent);
finish();
}
});
}