简体   繁体   中英

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 class. 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 ;) )!

知道了:只需将listadapter定义为listactivity内部的子类,现在您可以引用这些方法而无需将其标记为“静态”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM