0
데이터베이스에 의해 채워지는 listview를 사용하고 있습니다. 선택한 listView 항목에서 텍스트를 가져와야하지만 어떤 메서드를 사용해야하는지 잘 모릅니다. 설명해 주시겠습니까? 여기선택한 목록보기 항목에서 텍스트를 가져 오는 방법
내 코드 :
public class UserActivity extends ActionBarActivity{
public static ArrayList<String> ArrayofName = new ArrayList<String>();
private ListView listView;
public static String item_name = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_activity);
DataHandler db = new DataHandler(this);
List<Data> items = db.getTitle();
listView = (ListView) findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, ArrayofName);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
//here i should take text from selected item
}
});
}
}
감사합니다! :) – xXJohnRamboXx
당신은 이것을 가장 좋은 대답으로 받아 들일 수 있습니다 :) –