android


Autoclick search button (android)


Okay,I've been following this tutorial http://coenraets.org/blog/android-samples/androidtutorial/
Basically it gives me exactly what i need for my app
ONLY , I need the search button (or query) to be autoclicked...
I want the user to open the app and see the list already queried
also I have integrated this tutorial into a Tab application, so keep that in mind...
Please any help would be amazing!!! thank you a lot for taking time out of your lives to help me with this stupid thing
I'm a complete noob , I'm learning as I go
Thanka a lot again!
Fadi
I think the best way to achieve 'autoclicking' would be through the textwatcher-interface:
http://developer.android.com/reference/android/text/TextWatcher.html
Like this:
EditText.addTextChangedListener(...)
afterTextChanged(Editable s)
{
//Make your query here using s.getText().toString
//as your WHERE-Clause
}
I would advise you, to debug while using the TextWatcher just to understand how it works ;)
You should also consider that this method could use up a lot of memory, since you query your database with every letter that is typed. You could count the letters typed though, in
onTextChanged(CharSequence s, int start, int before, int count)
and setting a boolean value to true, when the user has typed more then 2 letters and start querying your DB then to avoid too much memory usage.
Edit:
This is the original search-Method:
public void search(View view) {
// || is the concatenation operation in SQLite
cursor = db.rawQuery("SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?",
new String[]{"%" + searchText.getText().toString() + "%"});
adapter = new SimpleCursorAdapter(
this,
R.layout.employee_list_item,
cursor,
new String[] {"firstName", "lastName", "title"},
new int[] {R.id.firstName, R.id.lastName, R.id.title});
employeeList.setAdapter(adapter);
}
Now try it like this:
searchText.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
#Override
afterTextChanged(Editable s){
// || is the concatenation operation in SQLite
cursor = db.rawQuery("SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?",
new String[]{"%" + s.getText().toString() + "%"});
adapter = new SimpleCursorAdapter(
this,
R.layout.employee_list_item,
cursor,
new String[] {"firstName", "lastName", "title"},
new int[] {R.id.firstName, R.id.lastName, R.id.title});
employeeList.setAdapter(adapter);
}
});
There are some blanks in the code which you have to fill in by yourself. But that's the basic idea behind my first post.
Look here http://developer.android.com/reference/android/text/TextWatcher.html
Try this:
EditText searchTo = (EditText)findViewById(R.id.medittext);
searchTo.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable s) {
}
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// autoclicked here!
}
});

Related Links

Insert data into SQLite table in the same row
Skewed ListView in Android
How open Url after Firebase message received in background
Detect soft navigation bar availability in onePlusOne device progmatically?
Cast HLS Live stream URL to Cast Device with Cast Companion Library
Calculate time difference between two EditText
Cannot retrieve error message from server in Error Listener of Volley in Android
How to detect android device rotation parallel to the ground?
JSONObject.put(string,string) not working
invalid param in LinerLayout:layout.weight? [closed]
Picasso onBitmapLoaded returns bitmap but not being drawn on canvas
I got the error when I am trying to delete items of Recycler View
How to transmit an Eddystone Beacon with Url using Altbeacon Library for Android
how can I change colour of list item background after it has been uploaded to an ERP server?
ListView with dynamic number of EditTexts containning rows
BURP and Fiddler don't detect WebSockets on Android/iOS?

Categories

HOME
cobalt
themes
alsa
google-apps
visual-studio-emulator
onclick
code-coverage
modal-dialog
x-cart
symmetricds
scrolltop
libusb
cfml
solrcloud
gulp-watch
pagespeed
react-toolbox
direct3d11
roundup
ckfinder
syntax-highlighting
jackson-modules
asymptotic-complexity
android-maps
progress-bar
genexus-sd
inversion-of-control
tpm
bioinformatics
userdefaults
laravel-eloquent
wacom
activexobject
html-encode
pdw-file-browser
sharepoint-workflow
xdocreport
hackintosh
kill
oracle-service-bus
show-hide
proget
clarifai
facebook-pixel
configurationmanager
activeperl
openblas
java-bytecode-asm
grails-plugin
scaffolding
avspeechsynthesizer
qiime
sklearn-pandas
jparsec
toast
design-principles
dllimport
forwarding
canalyzer
haskell-warp
apache-commons-daemon
omnifaces
google-refine
j-security-check
wcm
gnumeric
hibernate-entitymanager
gd-graph
kendo-dataviz
kogrid
ui-select2
time.h
scmmanager
mantle
faye
infobright
virtualpathprovider
box2d-iphone
jquery-tools
mbeans
cuteeditor
unattended-processing
non-clustered-index
easyb
dot-emacs
zen
skype4java
web-application-project
lemmatization
wcf-proxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App