So basically I have an Activity with a layout that shows my custom SurfaceView and an invisible EditText.
How can I call setVisibility(VISIBLE) on that object? I do use post(Runnable...) on my SurfaceView object, but the problem is findViewById(my EditText id) returns null?
I found why but how do I solve it?
Also, how do I recive a callback from the "Done" button on the EditText? Is it the same as the enter key?
You need to search for id.content on the view that has it as a child. So use the following:
TextView t = (TextView) getParent().findViewById(R.id.contents);
To answer your other question, to find when the user hits the enter key, use
t.setOnEditorActionListener(...)
Related
Help me, please! How can I set an order to changing focus in gridview with edittexts?
Now it looks like this:
(1)(2)(3)
(4)(5)(6)
(7)(8)(9)
When I press "Next" on keyboard, focus move 1-4-7 finish 2-5-8 finish 3-6-9. I need 1-2-3-4-5-6-7-8-9... items adding dynamically.
Get an instance of your EditText in the code, then call edittext1.setNextFocusDownId(R.id.edittext2); and hence do this for all youre EditText.
I am building an edit in place listView. That is, the user is looking at a list of TextView items. Then the user touches one, indicating he'd like to edit it. The selected item is now shown as an EditText, in the same ListView as the other TextView items.
After this, the soft keyboard is shown, but the EditText has actually lost focus because of all the redrawing. I've got a handle on the EditText in SimpleCursorAdapter.getView(). But, calling EditText.requestFocus() is futile unless I can be sure the EditText is there on the screen.
In which method of which class will I be able to execute something like, getListView().findItemById(n).requestFocus(); ?
Thank you very much.
You can execute
getInstrumentation().waitForIdleSync()
to wait for all UI events.
I have some text views in an linear layout in my android application. Next to them I want to put a small question mark of the form [?], that when tapped displays a popup with some information. I could do this with a button but it would be very big.
Is there any simple way of doing this?
You could set the question mark in a new TextView, and set a click listener via the onClickListener(View.OnClickListener l). From there you could use the getId() method to determine the question mark that was called. Then, you could use a switch statement, to split your programflow, and to whatever you want inside the switch statement.
TextView in the Android Reference:
http://developer.android.com/reference/android/widget/TextView.html
You could use a TextView with the text ?.
set the width to wrap_content
handle the onClick event to open the popup
use TextView to show ? and use PopupWindow for showing message as on textview click :
TextView t = (TextView)findViewById(R.id.TextView01);
t.setOnClickListener(this);
}
public void onClick(View arg0) {
// OPEN PopupWindow HERE
}
and how we create popupwindow you can see this tutorial for help:
Example of using PopupWindow
I am developing an application for Android, and for that I am trying to make a ListView act in such a way, that when a user presses an empty entry, he can start typing text directly into that empty entry, and that when the user touches any other part of the screen, it is saved. Is there a way to do this? I was thinking of using onClick somehow, but I have no concrete approach.
Here is one basic, general approach:
For each row of the ListView, create a layout that has a visible TextView and a EditText with the visibility set to gone.
Use an onClickListener for each row to swap the visibilities of the TextView and EditText (respectively, gone and visible) when the row is selected.
Track the active row for clicks to another row or background.
When the active row changes, set the value of the EditText to the TextView and return them to their original visible states.
Other approach that could be taken is using the View.OnFocusChangeListener and the TextWatcher you can get more detail about them here http://developer.android.com/reference/packages.html
I have a listview , on top of it there is a auto complete textview. Onclick of listview and autocomplete textview text ,it goes the detail activity. when back button is pressed,it comes from detail activity to list view page but the autocomplete textview contains same searched product term. How can i keep it empty so that it is ready to type(in stead of deleting it again and again)?
Thanks..
One way would be in your onResume() method in activity, get the reference to your AutoCompleteTextView and use setText() method to set text as empty. and use requestFocus() to give focus to AutocompleteTextview.