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

Expandable RecyclerView and custom ui
Android RadarChart click event on the container
Android handling click on notification
Permissions are granted by default
How to display properly sized image from user gallery?
Parsing Nested JSON using gson
BlueTooth read service w/ CodenameOne
Android app stuck on black screen
How do I change the function that the button has to a different one?
How to control behavior of setScrollPosition in appwidget listview
Save text on external google drive android studio
Center align multi line html text to textview
Implementing an update to android app outside play store [closed]
MIT App inventor application error
Error:(45, 13) Failed to resolve: me.wangyuwei:LoadingiVew:1.0.5
Titanium Samsung Galaxy S7 close window shows white screen

Categories

HOME
windows
httparty
fabricjs
awk
telegram
knitr
sublimetext
grafana
echo
pearson-correlation
polling
lanczos
performancepoint
extjs4.2
jquery-ui-sortable
octave
dkim
endeca
heat
altera
azure-iot-hub
feathersjs
template-engine
visual-studio-extensions
pchart
short-url
beta
game-theory
froala
corpus
entity-relationship-model
genexus-sd
sqlpackage
finagle
mockjax
jett
sammy.js
carriage-return
imx6
fiware-cygnus
numpy-broadcasting
openalpr
dm-script
flatmap
protein-database
unordered-map
azure-arm
watchface
placeholder
wc
berkeley-db-je
httr
opennms
hammer.js
stdmap
appdomain
opengl-4
filehandle
boo
google-photos
donations
iotivity
macaulay2
jquery-jscrollpane
hadoop-partitioning
ikiwiki
upx
html-to-pdf
cortex-m
pushbots
blitline
mobiledoc-kit
jaunt-api
relativelayout
toran-proxy
r-package
opserver
coda
toolkit
finalbuilder
rdflib
telepat
teamcity-9.1
mass-assignment
rapidsvn
theos
punycode
iso-prolog
jama
create.js
kissfft
personalization
rcaller
cancellation
square-bracket
notorm
insert-id
twisted.web
asplinkbutton
idn
uimanageddocument
dajaxice
landscape-portrait
drawtobitmap
django-paypal
codebase
object-database
dot-emacs
interprocess
leader

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App