Search in sources :

Example 16 with RadioButton

use of android.widget.RadioButton in project enroscar by stanfy.

the class RelativeRadioGroup method addView.

@Override
public void addView(final View child, final int index, final ViewGroup.LayoutParams params) {
    if (child instanceof RadioButton) {
        final RadioButton button = (RadioButton) child;
        if (button.isChecked()) {
            mProtectFromCheckedChange = true;
            if (mCheckedId != -1) {
                setCheckedStateForView(mCheckedId, false);
            }
            mProtectFromCheckedChange = false;
            setCheckedId(button.getId());
        }
    }
    super.addView(child, index, params);
}
Also used : RadioButton(android.widget.RadioButton)

Example 17 with RadioButton

use of android.widget.RadioButton in project Shuttle by timusus.

the class TracksListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder;
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.tracks_row_layout, parent, false);
        holder = new Holder((TextView) convertView.findViewById(R.id.text), (RadioButton) convertView.findViewById(R.id.radio));
        convertView.setTag(holder);
    } else {
        holder = (Holder) convertView.getTag();
    }
    holder.radio.setTag(position);
    holder.radio.setChecked(mSelectedPosition == position);
    convertView.setOnClickListener(this);
    holder.label.setText(mTracks.get(position).getName());
    return convertView;
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) RadioButton(android.widget.RadioButton)

Example 18 with RadioButton

use of android.widget.RadioButton in project coursera-android by aporter.

the class SamplerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // 
    final ImageButton button = (ImageButton) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message 
            Toast.makeText(SamplerActivity.this, "Beep Bop", Toast.LENGTH_SHORT).show();
        }
    });
    final EditText edittext = (EditText) findViewById(R.id.edittext);
    edittext.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "Done" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Show Toast message 
                Toast.makeText(SamplerActivity.this, edittext.getText(), Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });
    final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
    checkbox.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message indicating the CheckBox's Checked state
            if (((CheckBox) v).isChecked()) {
                Toast.makeText(SamplerActivity.this, "CheckBox checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "CheckBox not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
    final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
    radio_red.setOnClickListener(radio_listener);
    radio_blue.setOnClickListener(radio_listener);
    final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
    togglebutton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Perform action on clicks
            if (togglebutton.isChecked()) {
                Toast.makeText(SamplerActivity.this, "ToggleButton checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "ToggleButton not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);
    ratingbar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(SamplerActivity.this, "New Rating: " + rating, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : EditText(android.widget.EditText) ToggleButton(android.widget.ToggleButton) OnRatingBarChangeListener(android.widget.RatingBar.OnRatingBarChangeListener) RadioButton(android.widget.RadioButton) View(android.view.View) RatingBar(android.widget.RatingBar) KeyEvent(android.view.KeyEvent) ImageButton(android.widget.ImageButton) CheckBox(android.widget.CheckBox) OnClickListener(android.view.View.OnClickListener) OnKeyListener(android.view.View.OnKeyListener)

Example 19 with RadioButton

use of android.widget.RadioButton in project ARChon-Packager by bpear96.

the class activityInstalled method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.installed_list);
    g.setstep(0);
    //Open either file explorer
    if (selection == 1) {
        // Open file selector
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("file/*");
        startActivityForResult(intent, PICKFILE_RESULT_CODE);
    }
    if (selection == 0) {
        AsyncTask<Void, Void, Void> task = new //Start progress dialog and run task in background
        AsyncTask<Void, Void, Void>() {

            @Override
            protected void onPreExecute() {
                pd = new ProgressDialog(activityInstalled.this);
                pd.setTitle("Processing...");
                pd.setMessage("Please wait.");
                pd.setCancelable(false);
                pd.setIndeterminate(true);
                pd.show();
            }

            @Override
            protected Void doInBackground(Void... arg0) {
                //or list installed apps
                //Create TreeMap to store list of apps.
                map = new TreeMap<String, Button>();
                // This is the id of the RadioGroup we defined
                appButtonLayout = (ViewGroup) findViewById(R.id.installed_radio_group);
                //Generate list of apps installed
                List<PackageInfo> PackList = getPackageManager().getInstalledPackages(0);
                for (int i = 0; i < PackList.size(); i++) {
                    PackageInfo PackInfo = PackList.get(i);
                    if ((PackInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                        // Do not use system apps. Only user/data apps.
                        final String AppName = PackInfo.applicationInfo.loadLabel(getPackageManager()).toString();
                        RadioButton buttonr = new RadioButton(activityInstalled.this);
                        //Set text of button to applications name
                        buttonr.setText(AppName);
                        buttonr.setId(i);
                        //Put buttons in TreeMap
                        map.put(AppName, buttonr);
                        buttonr.setOnClickListener(new //When app radio button is selected
                        View.OnClickListener() {

                            @Override
                            public void onClick(View view) {
                                ((RadioGroup) view.getParent()).check(view.getId());
                                //store AppID
                                SelectedAppId = view.getId();
                                //Store App name
                                SelectedAppName = AppName;
                                Toast.makeText(activityInstalled.this, "App selected.", Toast.LENGTH_LONG).show();
                                //Save variables for next fragment
                                // Sets global variable
                                g.setSelectedAppId(SelectedAppId);
                                g.setSelectedAppName(SelectedAppName);
                                AsyncTask<Void, Void, Void> task = new //Start progress dialog and run task in background
                                AsyncTask<Void, Void, Void>() {

                                    @Override
                                    protected void onPreExecute() {
                                        pd = new ProgressDialog(activityInstalled.this);
                                        pd.setTitle("Processing...");
                                        pd.setMessage("Please wait.");
                                        pd.setCancelable(false);
                                        pd.setIndeterminate(true);
                                        pd.show();
                                    }

                                    @Override
                                    protected Void doInBackground(Void... arg0) {
                                        pullAPk();
                                        return null;
                                    }

                                    @Override
                                    protected void onPostExecute(Void result) {
                                        if (pd != null) {
                                            pd.dismiss();
                                        }
                                    }
                                };
                                task.execute((Void[]) null);
                            }
                        });
                    }
                }
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                if (pd != null) {
                    for (Button b : map.values()) {
                        //Add buttons in TreeMap to view.
                        appButtonLayout.addView(b);
                    }
                    pd.dismiss();
                }
            }
        };
        task.execute((Void[]) null);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) AsyncTask(android.os.AsyncTask) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) ProgressDialog(android.app.ProgressDialog) View(android.view.View) RadioButton(android.widget.RadioButton) Button(android.widget.Button)

Example 20 with RadioButton

use of android.widget.RadioButton in project grafika by google.

the class RecordFBOActivity method onRadioButtonClicked.

/**
     * onClick handler for radio buttons.
     */
public void onRadioButtonClicked(View view) {
    RadioButton rb = (RadioButton) view;
    if (!rb.isChecked()) {
        Log.d(TAG, "Got click on non-checked radio button");
        return;
    }
    switch(rb.getId()) {
        case R.id.recDrawTwice_radio:
            mSelectedRecordMethod = RECMETHOD_DRAW_TWICE;
            break;
        case R.id.recFbo_radio:
            mSelectedRecordMethod = RECMETHOD_FBO;
            break;
        case R.id.recFramebuffer_radio:
            mSelectedRecordMethod = RECMETHOD_BLIT_FRAMEBUFFER;
            break;
        default:
            throw new RuntimeException("Click from unknown id " + rb.getId());
    }
    Log.d(TAG, "Selected rec mode " + mSelectedRecordMethod);
    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        rh.setRecordMethod(mSelectedRecordMethod);
    }
}
Also used : RadioButton(android.widget.RadioButton)

Aggregations

RadioButton (android.widget.RadioButton)82 View (android.view.View)43 TextView (android.widget.TextView)30 Button (android.widget.Button)16 CheckBox (android.widget.CheckBox)15 RadioGroup (android.widget.RadioGroup)14 Intent (android.content.Intent)11 EditText (android.widget.EditText)11 Bundle (android.os.Bundle)10 ViewGroup (android.view.ViewGroup)8 CompoundButton (android.widget.CompoundButton)8 ImageView (android.widget.ImageView)7 ScrollView (android.widget.ScrollView)7 RemoteException (android.os.RemoteException)6 AdapterView (android.widget.AdapterView)6 Test (org.junit.Test)6 LayoutInflater (android.view.LayoutInflater)5 SeekBar (android.widget.SeekBar)5 OnClickListener (android.view.View.OnClickListener)4 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)4