How to get progress values from SeekBar created in ListAdapter?
I'm curently working on my first Android app, which is my first pice of java code at all, i think I got pretty far already but now I'm stuck on the following topic:
I have a ListActivity which shows rowViews from a custom ListAdapter generated from json objects. Generaly there are 3 types of objects:
Rooms, which neither have a button nor a slider. Those are handled like this in my ListActivity:
@Override
protected void onListItemClick (ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Log.d(TAG,"Area" + l.getItemAtPosition(position).toString() + "clicked");
handleControlItemActions((JSONObject)l.getItemAtPosition(position));
}
Switchable devices, which have a toggle button to be switched on and off are handled like this (onObjectSwitch is defined in xml as onClick action for the button):
public void onObjectSwitch (final View view) {
Log.d(TAG,"Object" + view.getId()+ " clicked");
handleControlItemActions((JSONObject)l.getItemAtPosition(position));
}
Dimmable devices, which have a SeekBar, and here is my problem: I know the "onSeekBarChangeListener", but I have no clue how I can set it to the SeekBars which are inside the rowViews from my Activity cl开发者_如何学编程ass. The bars are created by the Listadapter like this:
case 1:
textView.setText((String)controlItem.get("name") + " " +(String)controlItem.getString("actual")+"°C");
slider.setVisibility(View.VISIBLE);
slider.setId(position);
slider.setProgress(controlItem.getInt("setPoint"));
slider.setMax(controlItem.getInt("max"));
break;
Can anyone tell me how to handle those sliders? Or am I not even on the right track to manage those widgets?
Thanks in advance to everyone (and sorry for my spelling ;) )!
Okay got it: just define the listadapter as a subclass inside of the listactivity, now you're able to reffere to the methods without flagging them "static".
精彩评论