Código Java:
Ver original
Pero lo que quisiera es que me hiciera un SELECT a la base de datos Sqlite para que conforme voy escribiendo en el campo de texto me vaya saliendo debajo una lista de los resultados obtenidos.
ElecBuscarCliente.java
Código Java:
Ver original
import android.app.ListActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; /** * Created by Ivan on 09/11/2015. */ public class ElecBuscarCliente extends ListActivity { private EditText txtInput; "Tunisie", "Ukrania", "Tchekozlovakia" }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.buscar_clientes); final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries); setListAdapter(adapter); txtInput = (EditText) findViewById(R.id.state_name); txtInput.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable theWatchedText) { } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // Toast.makeText(getApplicationContext(), "BTC " + arg0, // 1).show(); } public void onTextChanged(CharSequence arg0, int start, int count, int after) { adapter.getFilter().filter(arg0.toString()); // Toast.makeText(getApplicationContext(), "OTC " + arg0, // 1).show(); } }); // addTextChangedListener lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { int position, long id) { Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); } }); /* AutoCompleteTextView textView=(AutoCompleteTextView)findViewById(R.id.autocomplete_country); ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.layout.list_item, countries); textView.setAdapter(adapter);*/ } }
buscar_clientes.xml
Código Java:
Ver original
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TableRow android:layout_width="300dp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:weightSum="1"> <!-- Note: android:inputType is not supported in Android 1.5 --> <EditText android:layout_width="fill_parent" android:inputType="textNoSuggestions" android:layout_height="wrap_content" android:completionThreshold="1" android:id="@+id/state_name" /> </TableRow> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> android:id="@+id/android:list" android:layout_width="match_parent" android:layout_height="match_parent" android:drawSelectorOnTop="false" android:layout_marginLeft="7dp" android:layout_marginRight="7dp" /> </FrameLayout> </ScrollView> </LinearLayout>
Gracias