【问题标题】:what are android's UI guidelines regarding ratingbar什么是关于评级栏的 android 用户界面指南
【发布时间】:2014-08-26 04:05:32
【问题描述】:

是否有关于 Android 评分栏的指南?我正在开发一个android应用程序,我开发它的方式,我只能通过将它添加到对话框来设置和编辑某物的评级。

我想知道是否有关于评级栏的指南 - 可以将其放在对话框中吗?还是我应该做一个变通?

【问题讨论】:

  • 这不是 iOS。您在 Android 上拥有实际选择权,您的应用不会因为 UI 不像谷歌可能想要的那样工作而被拒绝。所以如果你想把它放在一个对话框中,那就去吧。
  • 谢谢!这是为我的硕士准备的,我需要根据 UI 指南记录我做出的每一个 UI 决定。如果 Android 说这不是好习惯,我就不能使用它。这就是我问的原因
  • 事情是这样的——Android 没有像 iOS 那样广泛的指导方针,部分原因是理念上的差异。
  • Android 拥有出色的design guidelines,几乎涵盖了应用程序设计的每个部分,从可用组件到导航模式再到排版和写作风格。您是否完全按照他们的要求行事当然仍取决于您。

标签: android rating


【解决方案1】:

RatingBar's documentation:

RatingBar 是 SeekBar 和 ProgressBar 的扩展,以星显示评分。使用默认大小的 RatingBar 时,用户可以触摸/拖动或使用箭头键来设置评分。较小的 RatingBar 样式 (ratingBarStyleSmall) 和较大的仅指标样式 (ratingBarStyleIndicator) 不支持用户交互,只能用作指标。

使用支持用户交互的 RatingBar 时,不鼓励将小部件放置在 RatingBar 的左侧或右侧。

当然支持可编辑的评分栏,并且RatingBar 的有效使用 - 一个很好的例子是用于对内容进行评分的 Google Play 商店。

【讨论】:

    【解决方案2】:

    我担心在适配器类中设置我的评分栏(如下所示)。我希望能够获得评级栏链接到的用户的位置。我能想到的唯一解决方法是将它放在一个对话框中(这就是我提出问题的原因)。我通过将onRatingChanged 中的位置设置为最终的onRatingChanged 解决了我的问题(如何从内部类访问位置)。在此处阅读:Making paramters final 关于最终属性。真的很有帮助。

    适配器类

    public class PersonAdapter extends ArrayAdapter<Person> {
    private Context context;
    private List<Person> people;
    
    public PersonAdapter(Context context, List<Person> people) {
        super(context, R.layout.person_layout, people);
        this.context = context;
        this.people = people;
    }
    
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) 
    {
        // if this is a new view, then inflate it
        View personView = convertView;
    
        if (personView == null) 
        {
            // get the inflater that will convert the person_layout.xml file
            // into an actual object (i.e. inflate it)
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
            // create a view to display the person's info
            personView = inflater
                    .inflate(R.layout.person_layout, parent, false);
    
            TextView txt1stTime = (TextView) personView
                    .findViewById(R.id.txt1stTime);
            txt1stTime.setText("1st time");
        } 
        else 
        {
            TextView txt1stTime = (TextView) personView
                    .findViewById(R.id.txt1stTime);
            txt1stTime.setText("Recycled");
        }
    
        // keep track of person this view is working with
        personView.setTag(people.get(position));
    
        // get text views that will hold strings
        TextView txtSurname = (TextView) personView
                .findViewById(R.id.txtSurname);
        TextView txtFirstname = (TextView) personView
                .findViewById(R.id.txtFirstname);
        RatingBar ratingBar = (RatingBar) personView
                .findViewById(R.id.ratingBar1);
    
    
         //Once selected, get the question which the rating is in 
        //Start asynctask and get all the details for that question to update
        //Send and update rating
        ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener()
        {
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser)
            {
                ratingBar.setRating(rating);
                String name = people.get(position).surname;
                Toast.makeText(getContext(),
                        "Rating set to:  " + rating + " for the position: " + position + " and user: " + name, Toast.LENGTH_SHORT).show();   
    
            }
        });
    
        // set text fields
        txtSurname.setText(people.get(position).surname);
        txtFirstname.setText(people.get(position).firstName);
    
        float rate = ratingBar.getRating();
        Toast.makeText(getContext(),
                "Rating is: " + rate, Toast.LENGTH_LONG).show();
        people.get(position).rating = rate;
        System.out.print(people.get(position).rating);
        // return view to ListView to display
        return personView;
    }
    

    我知道我的答案与我的实际问题没有直接联系,但如果有人遇到同样的问题,而是使用对话框,那么有一个解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2016-12-24
      • 1970-01-01
      • 2014-02-13
      • 2010-09-07
      • 1970-01-01
      相关资源
      最近更新 更多