How to putExtra() in Searchable Dictionary Example

Posted by sirlunchalot on Stack Overflow See other posts from Stack Overflow or by sirlunchalot
Published on 2010-05-27T01:50:54Z Indexed on 2010/05/27 2:41 UTC
Read the original article Hit count: 247

Filed under:
|

Hi, based on the Searchable Dictionary sample I tried to put extra data to a different activity.

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Spinner distance = (Spinner) findViewById(R.id.distanceSpinner);
    ArrayAdapter<CharSequence> adapterDistance = ArrayAdapter.createFromResource(
                this, R.array.distance, android.R.layout.simple_spinner_item);
    adapterDistance.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    distance.setAdapter(adapterDistance);
    Intent intent = getIntent();

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {         
            // handles a click on a search suggestion; launches activity to show word
         mapIntent = new Intent(this, Map.class);
         mapIntent.setData(intent.getData());         
         mapIntent.putExtra("Distance", distance.getSelectedItemPosition());
            startActivity(mapIntent);
            finish();
        }
}

In my Map Class Distance is always zero because distance.getSelectedItemPostion() gets the initialized value. How can I putExtra data with a click on a search suggestion? Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about android