아래와 같은 커스텀뷰를 만들었는덷요 버튼을 클릭하면 해당하는 디비의 x,y의 좌표값을 다른 액티비티로 넘겨줘서
맵을 띄워줄려고 하는데요 db의 첫번째 값밖에 넘어가지 않네요 어떻게 해야할지..
어떤 분이 settag를 써보라서 이와 같이 구현해보았는데 맞는건지 잘모르겠네요
리스트뷰의 해당 아이템들은 movetoposition을 통해 해당 아이템의 포지션을 알 수 있는데 버튼의 클릭이벤트는
어떤식으로 해줘야 할지 감이 안잡힙니다. 일주일째 맨붕입니다 . 좀 알려주세요!!!
어떤분이 settag를 이용하래서 나름 해본건데 잘안되네요
final TextView name=(TextView)view.findViewById(R.id.text);
final Button map = (Button)view.findViewById(R.id.btn);
MapInfo mi= new MapInfo();
mi.x=(cursor.getString(cursor.getColumnIndex("x")));
mi.y=(cursor.getString(cursor.getColumnIndex("y")));
name.setText(cursor.getString(cursor.getColumnIndex("name")));
map.setTag(mi);
map.setFocusable(false);
여기서는 리스트뷰의 내용을 클릭시 해당토스트를 출력합니다.
@Override
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
cursor.moveToPosition(position);
String str=cursor.getString(cursor.getColumnIndex("name"));
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
}
});
}
클릭이벤트에서 cursor를 어떻게 설정해야 할지 몰라서 고민입니다.
public void mOnClick( View v){
MapInfo mi=new MapInfo();
mi=(MapInfo) v.getTag();
String x=mi.x;
String y=mi.y;
Intent i = new Intent(this,test.class);
i.putExtra("message_text", x);
i.putExtra("message_text1", y);
startActivity(i);
}
테스트로 출력해보는 부분인데 처음 인덱스 값만 출력되네요
ttt=(TextView)findViewById(R.id.textView1);
tttt=(TextView)findViewById(R.id.textView2);
Intent intent1 = getIntent();
String text = intent1.getStringExtra("message_text");
String text2 = intent1.getStringExtra("message_text1");
ttt.setText(text);
tttt.setText(text2);
