In my MapView there are shown Balloons like this:http://www.codemobiles.com/forum/code-mobile-topic-4180.html (it´s more or less the same code) What I want: If I press Balloon 1 it should open the Detail View with the Information of 1 and when I press the Ballon 2 it should open the Detail View with the informations of 2
I added this to the Itemized Overlay: c.startActivity(new Intent(c.getApplicationContext(), QuoteDetail.class));
So when I press Balloon 1 its open the DetailView with Information 1 But when I press Balloon 2 its also open the DetailView with Information 1 How can I change this?
Here is my code: QuoteDetail:
private ImageView mImageView;
private TextView mQuote;
private TextView mInfo;
private TextView mEmail;
private TextView mTel;
private TextView mWww;
private int mPosition;
private DataSource mDataSource;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.quote_detail);
Intent i = getIntent();
mPosition = i.getIntExtra("position", 0);
mDataSource = new DataSource();
mImageView = (ImageView) findViewById(R.detail.image);
mQuote = (TextView) findViewById(R.detail.quote);
mInfo = (TextView) findViewById(R.detail.info);
mEmail = (TextView) findViewById(R.detail.email);
mTel = (TextView) findViewById(R.detail.tel);
mWww = (TextView) findViewById(R.detail.www);
mImageView.setImageResource(mDataSource.getmPhotoHdPool().get(mPosition));
mQuote.setText(getResources().getString(mDataSource.getmQuotePool().get(mPosition)));
mInfo.setText(getResources().getString(mDataSource.getmInfoPool().get(mPosition)));
mEmail.setText(getResources().getString(mDataSource.getmEmailPool().get(mPosition)));
mTel.setText(getResources().getString(mDataSource.getmTelPool().get(mPosition)));
mWww.setText(getResources().getString(mDataSource.getmWwwPool().get(mPosition)));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true; }
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_me: startActivity(new Intent(this, AboutmeActivity.class));;
break;
case R.id.menu_settings: startActivity(new Intent(this, SettingsActivity.class));;
break;
}
return true; }
}
QuoteReaderActvity:
public class QuoteAdapter extends BaseAdapter {
private Context mContext;
private LayoutInflater mInflator;
private DataSource mDataSource;
public QuoteAdapter(Context c) {
mContext = c;
mInflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mDataSource = new DataSource();
}
public int getCount() {
return mDataSource.getDataSourceLength();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView thumbnail;
TextView quote;
if(convertView == null) {
convertView = mInflator.inflate(R.layout.list_item_layout, parent, false);
}
thumbnail = (ImageView) convertView.findViewById(R.list.thumb);
thumbnail.setImageResource(mDataSource.getmPhotoPool().get(position));
quote = (TextView) convertView.findViewById(R.list.text);
quote.setText(mDataSource.getmQuotePool().get(position));
return convertView;
}
}
// Rest of QuoteReaderActivty class...
private ListView mListView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mListView = (ListView) findViewById(R.id.quotes_list);
mListView.setAdapter(new QuoteAdapter(this));
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
Intent i = new Intent(QuoteReaderActivity.this, QuoteDetail.class);
i.putExtra("position", position);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true; }
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_me: startActivity(new Intent(this, AboutmeActivity.class));;
break;
case R.id.menu_settings: startActivity(new Intent(this, SettingsActivity.class));;
break;
}
return true; }
}
DateSource:
public ArrayList<Integer> getmPhotoHdPool() {
return mDetail;
}
public ArrayList<Integer> getmWwwPool() {
return mWww;
}
public ArrayList<Integer> getmTelPool() {
return mTel;
}
public ArrayList<Integer> getmInfoPool() {
return mInfo;
}
public ArrayList<Integer> getmEmailPool() {
return mEmail;
}
public ArrayList<Integer> getmPhotoPool() {
return mList;
}
public ArrayList<Integer> getmQuotePool() {
return mText;
}
private void setupPhotoPool() {
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
mList.add(R.drawable.tcs_1);
}
private void setupQuotePool() {
mText.add(R.string.quote_1);
mText.add(R.string.quote_2);
mText.add(R.string.quote_3);
mText.add(R.string.quote_4);
mText.add(R.string.quote_5);
mText.add(R.string.quote_6);
mText.add(R.string.quote_7);
mText.add(R.string.quote_8);
mText.add(R.string.quote_9);
mText.add(R.string.quote_10);
mText.add(R.string.quote_001);
}
private void setupEmailPool() {
mEmail.add(R.string.email_1);
mEmail.add(R.string.email_2);
mEmail.add(R.string.email_3);
mEmail.add(R.string.email_4);
mEmail.add(R.string.email_5);
mEmail.add(R.string.email_6);
mEmail.add(R.string.email_7);
mEmail.add(R.string.email_8);
mEmail.add(R.string.email_9);
mEmail.add(R.string.email_10);
mEmail.add(R.string.email_001);
}
private void setupTelPool() {
mTel.add(R.string.tel_1);
mTel.add(R.string.tel_2);
mTel.add(R.string.tel_3);
mTel.add(R.string.tel_4);
mTel.add(R.string.tel_5);
mTel.add(R.string.tel_6);
mTel.add(R.string.tel_7);
mTel.add(R.string.tel_8);
mTel.add(R.string.tel_9);
mTel.add(R.string.tel_10);
mTel.add(R.string.tel_001);
}
private void setupWwwPool() {
mWww.add(R.string.www_1);
mWww.add(R.string.www_2);
mWww.add(R.string.www_3);
mWww.add(R.string.www_4);
mWww.add(R.string.www_5);
mWww.add(R.string.www_6);
mWww.add(R.string.www_7);
mWww.add(R.string.www_8);
mWww.add(R.string.www_9);
mWww.add(R.string.www_10);
mWww.add(R.string.www_001);
}
private void setupPhotoHDPool() {
mDetail.add(R.drawable.caming_hd_1);
mDetail.add(R.drawable.caming_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);
mDetail.add(R.drawable.camping_hd_1);}
private void setupInfoPool() {
mInfo.add(R.string.detail_1);
mInfo.add(R.string.detail_2);
mInfo.add(R.string.detail_3);
mInfo.add(R.string.detail_4);
mInfo.add(R.string.detail_5);
mInfo.add(R.string.detail_6);
mInfo.add(R.string.detail_7);
mInfo.add(R.string.detail_8);
mInfo.add(R.string.detail_9);
mInfo.add(R.string.detail_10);
mInfo.add(R.string.detail_001);
}
public int getDataSourceLength() {
return mList.size();
}
public DataSource() {
mList = new ArrayList<Integer>();
mText = new ArrayList<Integer>();
mInfo = new ArrayList<Integer>();
mDetail = new ArrayList<Integer>();
mEmail = new ArrayList<Integer>();
mTel = new ArrayList<Integer>();
mWww = new ArrayList<Integer>();
setupPhotoPool();
setupQuotePool();
setupInfoPool();
setupPhotoHDPool();
setupEmailPool();
setupTelPool();
setupWwwPool();
}
}
I am also use this link, http://www.codemobiles.com/forum/code-mobile-topic-4180.html some codes are added,
MyMap.java class
}
Here I comment some code, because here add two itemizedOverlay , so one is comment.
and MyItemizedOverlay.java class
}
Here modification code
press balloon two , we can change index position. we can pass index position through your intent.
provide your code , that only Easy the Explain.
In the Itemized Overlay onClick handler, add an intentExtra so you can pass identifying information to your QuoteDetail.class. More than likely you'll want to extend the ItemizedOverlay class with your own class, add member variable(s) that you can use to identify the item. Then simply access these member variables and pass them to QuoteDetail as intentExtras.