So say i am tring to use the AutoCompleteTextView suggestions to be
able to bring user to the .xml i have created. If you cant understand
please have a look here
http://stackoverflow.com/questions/8997684/autocompletetextview-or-searchdialog
Here are my codes, i marked errors in comment //
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class Search extends Activity
{
public void onCreate(Bundle savedInstanceSate)
{
super.onCreate(savedInstanceSate);
setContentView(R.layout.searchshop);
AutoCompleteTextView autoComplete = (AutoCompleteTextView)
findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.list_item, shops);
autoComplete.setAdapter(adapter);
autoComplete.setThreshold(1);
autoComplete.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int
position,
long arg3) {
Intent intent;
int index=999;
for(int i=0;i<shops.length;i++)
{
//Cannot refer to a non-final variable autoComplete
inside an inner class defined in a different method
if(shops[i].equals(autoComplete.getText().toString().trim()))
{
index=i;
break;
}
}
switch(index)
{
case 0:
//The constructor Intent(Search, int) is
undefined
intent=new Intent(Search.this, R.layout.adidas);
startActivity(intent);
setContentView(R.layout.adidas);
break;
case 1:
//The constructor Intent(Search, int) is
undefined
intent=new Intent(Search.this, R.layout.affin);
startActivity(intent);
setContentView(R.layout.affin);
break;
}
}
});
}
static final String[] shops = new String[]
{
"Adidas", " Affin Bank", "Alam Art", "Al Amin"
};
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en