无法在Android评级栏中获得评分值

时间:2012-09-06 10:34:00

标签: android android-listview

我没有完成使用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,除了评级星。 建议??

0 个答案:

没有答案