0

I have just recently built an android tablet app (looking to port it to Google TV now) which is in close analogy to the Facebook Android Scrumptious App tutorial. In particular the issue is in the section of "Show Friends" of that tutorial: http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/show-friends/

On the tablet when I touch the Select a Friend part of the ListView, it responds to the onClick. But on the Google TV using Dpad remote, this doesn't work. In particular, (after doing some Log) the onClick never gets called. I have written the part of the code from the tutorial where the onClick doesn't get called.

Just to summarize: This onClick DOES GET CALLED on android tablet and mobile. BUT DOES NOT GET CALLED when on Google TV and clicking using the Enter button on the remote control.

Any help on getting this onClick to get called on the Google TV platform would be most helpful.

    private class PeopleListElement extends BaseListElement {

public PeopleListElement(int requestCode) {
    super(getActivity().getResources().getDrawable(R.drawable.action_people),
          getActivity().getResources().getString(R.string.action_people),
          getActivity().getResources().getString(R.string.action_people_default),
          requestCode);
}

@Override
protected View.OnClickListener getOnClickListener() {
    return new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Supposed to do something here BUT ON GOOGLE TV DOES NOT GET CALLED
        }
    };
}
phwd
  • 19,975
  • 5
  • 50
  • 78
user1898014
  • 17
  • 1
  • 5

2 Answers2

0

what happens when you use the touchpad pointer to click the item? I suspect that it may be related to the layout hierarchy and that something higher up is grabbing the dpad event. Conversely it could be that dpad focus is not on the element you think it is.

Krispy
  • 1,098
  • 1
  • 7
  • 11
  • The layout hierarchy consists of a – user1898014 Apr 07 '13 at 04:28
  • if it was a layout hierarchy issue or a dpad focus issue, am i right in saying that the only thing needed to do would be to play around with focusable in the xml files? no need to look at the java code or anytihng else? – user1898014 Apr 07 '13 at 04:50
  • Are you using an OnClickListener for your list or an OnItemClickListener? I would advise using an OnItemClickListener attached to your list – Krispy Apr 08 '13 at 16:15
  • Using OnClickListener for the individual list items on the list and attaching this list to an adapter. Essentially for the problem I'm having, it's the same code as this part of the FB tutorial: http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/show-friends/ the adapter for the listView is the class called ActionListAdapter. new to the FB API and Google TV coding so i apologize if i sound amateur on this. I'll try to figure out how to use the OnItemClickListener for this FB tutorial code. – user1898014 Apr 09 '13 at 08:58
  • Have a look at http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html – Krispy Apr 09 '13 at 14:56
  • Thank! Got it to work using OnItemClickListener on the listview. – user1898014 Apr 11 '13 at 00:29
0

There are some bugs amongst the various Google TV devices not sending the right key codes for things like OK/Enter or the D-pad center. You might want to add a key listener to see what codes are getting sent to your view.

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17
  • pretty new to developing on Google TV, so are you talking about the KEY_DOWN method? and in my java files, would I put it on my Main Activity or the Fragments that are hosting this layout (selection.xml) – user1898014 Apr 07 '13 at 04:35
  • Yes, but you will have to extend the ListView to listen for events that are being sent to the list. Anything not handled by the ListView will go to its parent, so adding another key listener to the activity would be helpful too. – Leon Nicholls Apr 07 '13 at 12:28
  • Added a keylistener to the ListView which works, so i'm guessing the xml file (listitem.xml) which is on top of the ListView (which is in selection.xml) does not get called. The listitem.xml is on top of the ListView so it will have to be a focus problem where listitem.xml is not focusable. When I try putting focusable = true on the listitem.xml, it still doesn't work though. – user1898014 Apr 08 '13 at 00:15
  • Have you tried putting the user interface in a single xml file with a flat design so that nothing is obscuring the list control? – Leon Nicholls Apr 08 '13 at 00:52