rails使用bootstrap选择选项样式

时间:2016-03-06 13:39:31

标签: ruby-on-rails forms twitter-bootstrap ruby-on-rails-4 twitter-bootstrap-3

我在rails应用程序中有一个选择选项:

public class TableListAdapter extends RecyclerView.Adapter<TableListAdapter.TableViewHolder> {
  private Context context;

  public TableListAdapter(Context context) {
      this.context = context;
  }
  @Override
  public int getItemCount() {
        return tableList.size();
  }

  @Override
  public void onBindViewHolder(TableViewHolder tableViewHolder, int i) {

    /* update referenced UI fields in view holder */

    tableViewHolder.cv.setOnClickListener(new View.OnClickListener() {

          @Override
          public void onClick(final View v) {

              cardId = (int)v.getTag();

              Log.d("cardId", String.valueOf(cardId));

              t = tableList.get(cardId);
              id = t.getId();

              Log.d("Id",String.valueOf(id));

              editMode = true;
              Intent i = new Intent(timeTableList, NewTimeTable.class);
              i.putExtra("editMode", editMode);
              i.putExtra("tableId", id);
              timeTableList.startActivity(i);
          }
      });    

      tableViewHolder.cv.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(final View v) {
                // TODO Auto-generated method stub

                final AlertDialog.Builder builder = new AlertDialog.Builder(timeTableList);

                builder.setTitle("Delete Time Table")
                        .setMessage("Are you sure you want to Delete this Time Table?")
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {

                                cardId = (int)v.getTag();

                                Log.d("cardId", String.valueOf(cardId));

                                t = tableList.get(cardId);
                                id = t.getId();

                                t = db.getTable(id);
                                db.deleteTable(t);

                                Intent intent = new Intent(timeTableList,TimeTableList.class);
                                timeTableList.finish();
                                timeTableList.startActivity(intent);

                            }

                        })


                        .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // do nothing
                            }
                        })

                        .setIcon(R.drawable.ic_warning_black_36dp)
                        .show();
                return true;
            }

        });
  }

 @Override
 public TableViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

    /* Inflate view and pass it to view holder */
    View  itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.table_card, viewGroup, false);

    return new TableViewHolder(itemView);
 }

public static class TableViewHolder extends RecyclerView.ViewHolder {

    protected TextView tableTitle;
    protected CardView cv;
    protected SwitchCompat aSwitch;
    protected Button color;


    public TableViewHolder(View v) {
        super(v);

        cv = (CardView) v.findViewById(R.id.card_view);   // Reference your layout fields.

    }    
}

它工作正常,现在我试图用引导程序设置它,但不能让风格起作用。

这是关于引导指南的内容:

<%= f.select :willingToRelocate, ['Yes', 'No'] %>

还有一个指向引导样式文档的链接:http://getbootstrap.com/css/

1 个答案:

答案 0 :(得分:3)

您可以将其设置为<%= f.select :willingToRelocate, ['Yes', 'No'], {}, class: 'form-control'} %>

您可以查看this link。 api.rubyonils会提供大量信息,可用于解决这类问题。