Managing view's refresh delay and soft keyboard

by Mirthis » Tue, 09 Jun 2009 01:19:07 GMT


Sponsored Links
 I repost here what I've already written on the Android Developer group
cause it fit better here.

Hi to everyone. I start trying out some stuff with Android from few
days so there's lot I don't know but I hope not to sound too stupid.
Here are the first problems I'm facing

1) I have a ListView where each item is made of two icon (on the left
and right side) and an EditText, disabled, in the middle. I have a
button to add new element to the lists and what I want to happen is
that clicking on it a new lne appears in the ListView with the focus
on the EditText so that the user can type a label for the object.
What I tried to do when the button is clicked is:
- add a new object to the array binded to the ListView;
- notify the array adapter that a change as occoured in the data
- retrieve the view object for the last child added to the ListView
- set the focus on the EditText
The problem is that between the call of notifyDataSetChanged() and the
 creation of a new child in the ListView there's a delay and so I'm
not able to get the new created view in the click handler. What's the
best way to handle it?

2) Considering the same scenario when I give focus to the EditText I
see the cursor for editing the field value but the soft keyboard
doens't appear. That's perfect on a device with an hard keyboard, but
what would happen if the device doesn't have one?
The other thing I find weird is that when I tap the EditText the
keyboard finally appears but the field lost the focus so I can type
whatever I want but nothing appear in the field. This latest thing
seems to be in some way related to the fact the EditText is part of
the layout used to display each item in the list. Any idea on how to
solve it?

That's all, I hope it was fairly clear and to get some help.
Thank you for reading

Andrea

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. WebView in tabHost

I've put a little app together that has three tabs to show three
different web pages. It does work however I am bit worried I haven't
got enough control over how this whole thing works. When I click a
tab, I get a web page loaded (see code sample below), now when I click
another tab another page loads in another view. When I go back to the
first tab, the whole thing get initilized again and the page loads. Is
there a way how I can control this and keep the underneeth tab's
activity in its current state as long as I want (and say only
"refresh" the page when it changes).

do I need to handle onPause()/onResume() methods for that? How do I
store the state of my activity to avoid re-initializing it every time?

tabs.class:

intent = new Intent().setClass(this, tab_schedule.class);
                spec = tabHost.newTabSpec("Schedule").setIndicator("Schedule",
                                
res.getDrawable(R.drawable.tab_icon_schedule)).setContent(
                                intent);
                tabHost.addTab(spec);

the tab_schedule.class does a simple web page load:

@Override
        public void onCreate(Bundle savedInstanceState) {

                super.onCreate(savedInstanceState);
                setContentView(R.layout.tab_people);

                try {

                        WebView currentView = (WebView)
findViewById(R.id.tab_people_WebView);
                        currentView.getSettings().setJavaScriptEnabled(true);
                        currentView.loadUrl("http://pda.lenta.ru");

                } catch (Exception e) {
                        Log.v("webClientInit", e.getMessage());
                }
        }

-- 

2. How to trigger onTouch/onKeyPress event for '+' (plus) symbol

Hi,
In my app i would need to add dynamic table rows on touch(on key
event) of '+' (plus) symbol from the keypad.
The KeyListener()  was triggered for down/back keys but not for '+'. I
would appreciate if you let me know how i could trigger an onKey event
for '+'.

Regards,
Srikanth

-- 

3. Problem styleable custom attributes on custom view

4. editText not updated

5. Problem with Audio Record and Audio Track

6. HTC Wildfir

7. Samsung Galaxy suitable for development work?