사진에서 보이듯이 스피너에서 조건을 걸고 텍스트로 검색하는 건데요
예를 들어서
'업종별' 을 선택하고 텍스트에는 '분식'으로 쿼리를 날리면 아래에 리스트가 쭉 뜨는것입니다.
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
}
이 함수부분에 선택되었을 때 어떻게 써야 할지 ㅠ.ㅜ
스피너에 조건이 업종별, 위치별, 음식점이름 이 있습니다.
이 셋중에 하나를 선택하는 조건을 걸어도 텍스트로 받는 조건이 ㅠ.ㅠ
아래에 좀더 참조하시라고 적어드렸습니다
public class SampleSpinnerActivity extends Activity implements AdapterView.OnItemSelectedListener {
EditText edit01;
SQLiteDatabase database;
String tableName = "foodinfo";
DatabaseHelper helper;
ListView list01;
String[] items = { "업종별", "위치별", "음식점이름" };
Spinner spin;
String a;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
list01 = (ListView) findViewById(R.id.list01);
edit01 = (EditText) findViewById(R.id.editText);
// Button searchBtn = (Button) findViewById(R.id.searchBtn);
spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String> aa = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, items);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
Button searchBtn = (Button) findViewById(R.id.searchBtn);
searchBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
createDatabase();
Cursor cursor = queryData1();
if(cursor != null) {
startManagingCursor(cursor);
String[] columns = {"_id", "name", "class"};
int[] resIds = {R.id.text01, R.id.text02, R.id.text03};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getApplicationContext(),R.layout.listitem , cursor, columns, resIds);
list01.setAdapter(adapter);
}
}
});
}
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {