Search in sources :

Example 51 with RadioButton

use of android.widget.RadioButton in project Ruisi by freedom10086.

the class FrageHotsNews method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    ((RadioButton) mRootView.findViewById(R.id.btn_1)).setText("新帖");
    mRootView.findViewById(R.id.btn_2).setVisibility(View.GONE);
    ((RadioButton) mRootView.findViewById(R.id.btn_3)).setText("热贴");
    postList = mRootView.findViewById(R.id.recycler_view);
    refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    postList.setLayoutManager(mLayoutManager);
    postList.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    // 设置可以滑出底栏
    postList.setClipToPadding(false);
    postList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    adapter = new HotNewListAdapter(getActivity(), mydataset, galleryDatas);
    postList.setAdapter(adapter);
    postList.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) mLayoutManager, this, 10));
    refreshLayout.setOnRefreshListener(this::refresh);
    RadioGroup swictchMes = mRootView.findViewById(R.id.btn_change);
    swictchMes.setOnCheckedChangeListener((radioGroup, id) -> {
        int pos = -1;
        if (id == R.id.btn_1) {
            pos = TYPE_NEW;
        } else {
            pos = TYPE_HOT;
        }
        if (pos != currentType) {
            currentType = pos;
            refreshLayout.setRefreshing(true);
            refresh();
        }
    });
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) HotNewListAdapter(me.yluo.ruisiapp.adapter.HotNewListAdapter) RadioGroup(android.widget.RadioGroup) RecyclerView(android.support.v7.widget.RecyclerView) RadioButton(android.widget.RadioButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 52 with RadioButton

use of android.widget.RadioButton in project CSCI3130 by T-Caines.

the class CourseViewer method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_course_view);
    spinner = findViewById(R.id.viewSpinner);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (spinner.getSelectedItem().toString().equals("Show All")) {
                lock(true, false, false);
            } else if (spinner.getSelectedItem().toString().equals("Show Non-Conflicting")) {
                lock(false, true, false);
            } else if (spinner.getSelectedItem().toString().equals("Show Schedule")) {
                lock(false, false, true);
            }
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        String uid = user.getUid();
        mDatabase = FirebaseDatabase.getInstance().getReference().child("USERDATA").child(uid);
    }
    firebaseAdapter = new FirebaseListAdapter<Course>(this, Course.class, R.layout.list_view, FirebaseDatabase.getInstance().getReference("COURSE").child(ApplicationData.term.getTerm())) {

        @Override
        protected void populateView(View v, Course model, int position) {
            TextView seats = (TextView) v.findViewById(R.id.seats);
            seats.setText(String.format("%s/%s", model.enrollment, model.seatsAvailable));
            TextView code = (TextView) v.findViewById(R.id.code);
            code.setText(model.faculty + model.courseID);
            TextView courseName = (TextView) v.findViewById(R.id.name);
            courseName.setText(model.courseName);
            TextView timeEnd = (TextView) v.findViewById(R.id.end);
            timeEnd.setText("" + model.timeEnd);
            TextView timeStart = (TextView) v.findViewById(R.id.start);
            timeStart.setText("" + model.timeStart);
            TextView days = (TextView) v.findViewById(R.id.days);
            // TODO: Right method to convert binary 10101 -> MWF
            days.setText("" + model.days);
        }
    };
    // Create list view
    listView = findViewById(R.id.list_view);
    listView.setAdapter(firebaseAdapter);
    switch(ApplicationData.term) {
        case FALL:
            RadioButton fallRB = findViewById(R.id.fall);
            fallRB.setChecked(true);
            break;
        case WINTER:
            RadioButton winterRB = findViewById(R.id.winter);
            winterRB.setChecked(true);
            break;
        case SUMMER:
            RadioButton summerRB = findViewById(R.id.summer);
            summerRB.setChecked(true);
            break;
    }
    // Set what happens when a list view item is clicked
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @RequiresApi(api = Build.VERSION_CODES.M)
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Grab selected item from firebase
            selectedCourse = firebaseAdapter.getItem(position);
            // If there is an item already selected, un-highlight
            if (previousSelectedView != null) {
                previousSelectedView.setBackgroundColor(getColor(R.color.defaultBackground));
            }
            // Used to unselect a course. Happens when you select the selected item.
            if (previousSelectedView == view) {
                previousSelectedView = null;
                selectedCourse = null;
                return;
            }
            // Highlight this item
            view.setBackgroundColor(getColor(R.color.colorBalanced));
            previousSelectedView = view;
        }
    });
    Button addButton = findViewById(R.id.addbutton);
    addButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (selectedCourse == null)
                return;
            if (!courseManager.capReached(selectedCourse, v)) {
                System.out.println("Adding failed");
            }
        }
    });
    Button dropButton = findViewById(R.id.dropbutton);
    dropButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (selectedCourse == null)
                return;
            if (selectedCourse.hasLab) {
                courseManager.dropLabContinue(selectedCourse, v);
            } else {
                courseManager.confirmDrop(selectedCourse, v);
            }
        }
    });
}
Also used : RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) RadioButton(android.widget.RadioButton) Button(android.widget.Button) RequiresApi(android.support.annotation.RequiresApi) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Course(ca.dal.cs.softeng.database.Course)

Example 53 with RadioButton

use of android.widget.RadioButton in project BlogSource by TeachCourse.

the class RadioButtonActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_radio_button);
    // 为RadioGroup单选按钮组添加监视器
    mRadioGroup = ((RadioGroup) findViewById(R.id.radiogroup1));
    mRadioGroup.setOnCheckedChangeListener(radioChange);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
    LayoutInflater inflater = getLayoutInflater();
    for (int i = 0; i < 5; i++) {
        RadioButton radioButton = (RadioButton) inflater.inflate(R.layout.radio_button, mRadioGroup, false);
        // RadioButton radioButton=new RadioButton(this);
        radioButton.setId(i);
        radioButton.setText("单选按钮" + i);
        radioButton.setButtonDrawable(null);
        radioButton.setLayoutParams(params);
        mRadioGroup.addView(radioButton);
    }
    // 为提交按钮添加监视器
    ((Button) findViewById(R.id.button1)).setOnClickListener(lick);
    initButton(getWindow().getDecorView());
}
Also used : RadioGroup(android.widget.RadioGroup) RadioButton(android.widget.RadioButton) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) RadioButton(android.widget.RadioButton) LinearLayout(android.widget.LinearLayout)

Example 54 with RadioButton

use of android.widget.RadioButton in project MifareClassicTool by ikarus23.

the class FileChooser method onFileChosen.

/**
 * Finish the Activity with an Intent containing
 * {@link #EXTRA_CHOSEN_FILE} and {@link #EXTRA_CHOSEN_FILENAME} as result.
 * You can catch that result by overriding onActivityResult() in the
 * Activity that called the file chooser via startActivityForResult().
 * @param view The View object that triggered the function
 * (in this case the choose file button).
 * @see #EXTRA_CHOSEN_FILE
 * @see #EXTRA_CHOSEN_FILENAME
 */
public void onFileChosen(View view) {
    RadioButton selected = (RadioButton) findViewById(mGroupOfFiles.getCheckedRadioButtonId());
    Intent intent = new Intent();
    File file = new File(mDir.getPath(), selected.getText().toString());
    intent.putExtra(EXTRA_CHOSEN_FILE, file.getPath());
    intent.putExtra(EXTRA_CHOSEN_FILENAME, file.getName());
    setResult(Activity.RESULT_OK, intent);
    finish();
}
Also used : Intent(android.content.Intent) RadioButton(android.widget.RadioButton) File(java.io.File)

Example 55 with RadioButton

use of android.widget.RadioButton in project MifareClassicTool by ikarus23.

the class FileChooser method onDeleteFile.

/**
 * Delete the selected file and update the file list.
 * @see #updateFileIndex(File)
 */
private void onDeleteFile() {
    RadioButton selected = (RadioButton) findViewById(mGroupOfFiles.getCheckedRadioButtonId());
    File file = new File(mDir.getPath(), selected.getText().toString());
    file.delete();
    mIsDirEmpty = updateFileIndex(mDir);
}
Also used : RadioButton(android.widget.RadioButton) File(java.io.File)

Aggregations

RadioButton (android.widget.RadioButton)198 View (android.view.View)100 TextView (android.widget.TextView)69 RadioGroup (android.widget.RadioGroup)43 Button (android.widget.Button)38 Intent (android.content.Intent)36 CheckBox (android.widget.CheckBox)28 EditText (android.widget.EditText)26 ImageView (android.widget.ImageView)21 CompoundButton (android.widget.CompoundButton)19 LayoutInflater (android.view.LayoutInflater)18 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)17 Bundle (android.os.Bundle)16 AdapterView (android.widget.AdapterView)15 DialogInterface (android.content.DialogInterface)14 Context (android.content.Context)10 ScrollView (android.widget.ScrollView)10 ArrayList (java.util.ArrayList)10 SharedPreferences (android.content.SharedPreferences)9