0

我没有使用 SimpleAdapter 在我的 ListView 中获得评级栏(具有固定评级值)。

这里设置评级值的代码:

String[] from={"nome","descrizione","prezzoVisita","valutazione","prezzoInterventoScontat‌​o","foto"}; 

int[] to={R.id.nomeClinica,R.id.descrizioneClinica,R.id.prezzoVisita,R.id.ratingBar1,R‌​.id.prezzoInterventoScontato,R.id.fotoClinica}; 
SimpleAdapter adapter=new SimpleAdapter( getApplicationContext(), cliniche,R.layout.cliniche_view,from, to);

adapter.setViewBinder(new ViewBinder() {

            public boolean setViewValue(View view, Object data,
                    String textRepresentation) {
                if(view.getId() == R.id.ratingBar1){
                    String val = (String) data.toString();
                    float ratingValue = Float.parseFloat(val);
                    RatingBar ratingBar = (RatingBar) view;
                    ratingBar.setRating(ratingValue);
                    return true;
                }

                    return false;
                }
            } );
         ((ListView)findViewById(R.id.clinicheListView)).setAdapter(adapter);
         ListView listView = (ListView)findViewById(R.id.clinicheListView);

我得到了 ListView,除了评级明星。建议??

4

0 回答 0