last day (14 days later) » 

11:11 AM
0
A: List view Focus while using D-PAD

vandusMake a dummy view without background and place it in the same layout as your listview. Make it focusable and set nextFocusRight of your Search view to id/dummy. <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="wrap_content" android:c...

 
i tried above idea,it is not working.If search button has focus i click right D-Pad button ,now dummy view and list view both getting focused.
 
did you make dummy view focusable in xml?
 
yes i did that one
 
How do you know they both have focus? They actually cannot have focus at the same time. Try making the dummy view be to the left of listview. (android:toLeftOf=listview).
 
I am using linear layout, android:toLeftOf is not available
 
11:11 AM
Then just place the dummy view before the listview.
 
i have did the code like that only.
 
Sorry?
 
hi
 
hi
I did not understand your last comment
If you use linear layout, you must place the dummy View above ListView, not like in the code I sent you
 
i mentioned dummy code in above of the list view only
 
11:14 AM
so do you have it like this?
<View android:id="@+id/dummy"/>
<ListView..../>
 
yes exactly
 
where in code do you set the onFocusChangeListener?
 
i mentioned inside the oncreate method
 
does it get called?
try to put a Log in the onFocusChanged method
if it is called
 
ok
please stay online,i am checking
 
11:24 AM
ok
it is definitely working for me
what platform are you developing for?
 
platform in the sense
android and java
 
what API?
 
Rest
 
I mean the Android API level...
 
API level 10
 
11:29 AM
maybe thats why it is not working
why are you developing for such an old API?
 
this thing not for all devices.its for car display project
That car display library coded for API level 10 only
 
Ok then try this:
in the onFocusChanged method, write this:
 
this fully related to car device,every thing have to handle by using D-PAD only
 
listView.requestFocus
just this one line
okay and
one more thing to change
you must place the dummy view above the listview
so if you give background color to the dummy view, it is displayed right above the listview
do you understand?
 
yes ,i got
 
11:34 AM
now it shoudl work
 
ok
 
is it working?
 
nope,it is not working
 
you must now set a selector to the listview again
it is a compleetely different solution
 
Already i have set the selector
 
11:42 AM
to the listview?
 
Yes,exactly
 
in onFocusChange method:
listView.setSelection(0)
listView.requestFocus()
can you paste your code here?
 
dummy.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
@Override public void onFocusChange(View v, boolean hasFocus)
{
if (hasFocus)
{
listViewSearch.post(new Runnable() {
@Override
public void run() {
listViewSearch.requestFocus();
listViewSearch.setSelection(0);
}
});
}
}
});
 
delete the post and new Runnable part
and keep only these two lines:
listView.setSelection(0)
listView.requestFocus()
 
ok
 
12:02 PM
not working
 
then I think I cant help you any more
the API is just old
you should consider upgrading the API for the car anyway
 
ok,thank you for yor response..!
 
so my answer to your question works for API above Gingerbread
 
ok
 

last day (14 days later) »