Search in sources :

Example 11 with RadioGroup

use of android.widget.RadioGroup in project ScrollableTabHost-for-Android by honcheng.

the class ScrollableTabActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    activityManager = getLocalActivityManager();
    setContentView(R.layout.customslidingtabhost);
    contentViewLayout = (LinearLayout) findViewById(R.id.contentViewLayout);
    bottomBar = (HorizontalScrollView) findViewById(R.id.bottomBar);
    bottomRadioGroup = (RadioGroup) findViewById(R.id.bottomMenu);
    contentViewLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    defaultOffShade = RadioStateDrawable.SHADE_GRAY;
    defaultOnShade = RadioStateDrawable.SHADE_YELLOW;
    /*
         *  alternative method to using XML for layout, not used
         */
    /*
        if (inflateXMLForContentView())
        {
        	contentViewLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 
        }
        else
        {
        	RelativeLayout mainLayout = new RelativeLayout(this);
            RelativeLayout.LayoutParams mainLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
            mainLayout.setLayoutParams(mainLayoutParams);
            contentViewLayout = new LinearLayout(this);
            contentViewLayout.setOrientation(LinearLayout.VERTICAL);
            contentViewLayout.setBackgroundColor(Color.WHITE);
            contentViewLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
            contentViewLayoutParams.bottomMargin = 55;
            mainLayout.addView(contentViewLayout, contentViewLayoutParams);
            bottomBar = new HorizontalScrollView(this);
            //bottomBar.setHorizontalFadingEdgeEnabled(false);
            RelativeLayout.LayoutParams bottomBarLayout = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 55);
            bottomBarLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            mainLayout.addView(bottomBar, bottomBarLayout);
            bottomRadioGroup = new RadioGroup(this);
            bottomRadioGroup.setOrientation(RadioGroup.HORIZONTAL);
            LayoutParams bottomRadioGroupLayoutParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
            bottomRadioGroup.setLayoutParams(bottomRadioGroupLayoutParam);
            bottomBar.addView(bottomRadioGroup);
            if (bottomBar()!=-1) bottomBar.setBackgroundResource(bottomBar());
            //bottomBar.setBackgroundResource(R.drawable.bottom_bar);
            setContentView(mainLayout);
        }*/
    bottomRadioGroup.setOnCheckedChangeListener(this);
    intentList = new ArrayList();
    titleList = new ArrayList();
    states = new ArrayList();
    buttonLayoutParams = new RadioGroup.LayoutParams(320 / 5, RadioGroup.LayoutParams.WRAP_CONTENT);
}
Also used : RadioGroup(android.widget.RadioGroup) ArrayList(java.util.ArrayList) LinearLayout(android.widget.LinearLayout)

Example 12 with RadioGroup

use of android.widget.RadioGroup in project JamsMusicPlayer by psaravan.

the class GooglePlayMusicFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;
    View rootView = (View) inflater.inflate(R.layout.fragment_welcome_screen_5, null);
    welcomeHeader = (TextView) rootView.findViewById(R.id.welcome_header);
    welcomeHeader.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Light"));
    welcomeText1 = (TextView) rootView.findViewById(R.id.welcome_text_1);
    welcomeText1.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Regular"));
    googlePlayMusicDisclaimer = (TextView) rootView.findViewById(R.id.google_play_music_disclaimer);
    googlePlayMusicDisclaimer.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Regular"));
    radioGroup = (RadioGroup) rootView.findViewById(R.id.google_play_music_radio_group);
    final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    //We're adding 1 here to account (no pun intended) for the extra "Don't use Google Play Music" option.
    final int size = accounts.length + 1;
    final RadioButton[] radioButton = new RadioButton[size];
    //Add a new radio button the group for each username.
    for (int i = 0; i < size; i++) {
        radioButton[i] = new RadioButton(getActivity());
        radioGroup.addView(radioButton[i]);
        //The first radio button will always be "Don't use Google Play Music".
        if (i == 0) {
            radioButton[i].setChecked(true);
            radioButton[i].setText(R.string.dont_use_google_play_music);
        } else {
            radioButton[i].setText(accounts[i - 1].name);
        }
        radioButton[i].setTag(i);
        radioButton[i].setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    }
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            int radioButtonID = group.getCheckedRadioButtonId();
            View radioButton = group.findViewById(radioButtonID);
            int index = group.indexOfChild(radioButton);
            if (index != 0) {
                account = accounts[index - 1];
                mApp.getSharedPreferences().edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit();
                AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, getActivity(), true, account.name);
                task.execute();
            } else {
                mApp.getSharedPreferences().edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", "").commit();
                mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false).commit();
            }
        }
    });
    return rootView;
}
Also used : Account(android.accounts.Account) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) AsyncGoogleMusicAuthenticationTask(com.jams.music.player.AsyncTasks.AsyncGoogleMusicAuthenticationTask) AccountManager(android.accounts.AccountManager) RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View) Paint(android.graphics.Paint)

Example 13 with RadioGroup

use of android.widget.RadioGroup in project httpclient by pixmob.

the class CustomNavigation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    //Used for theme switching in samples
    setTheme(SampleList.THEME);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text);
    ((TextView) findViewById(R.id.text)).setText(R.string.custom_navigation_content);
    //Inflate the custom view
    View customNav = LayoutInflater.from(this).inflate(R.layout.custom_view, null);
    //Bind to its state change
    ((RadioGroup) customNav.findViewById(R.id.radio_nav)).setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            Toast.makeText(CustomNavigation.this, "Navigation selection changed.", Toast.LENGTH_SHORT).show();
        }
    });
    //Attach to the action bar
    getSupportActionBar().setCustomView(customNav);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
}
Also used : OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 14 with RadioGroup

use of android.widget.RadioGroup in project robolectric by robolectric.

the class ShadowRadioButtonTest method shouldInformRadioGroupThatItIsChecked.

@Test
public void shouldInformRadioGroupThatItIsChecked() throws Exception {
    RadioButton radioButton1 = new RadioButton(RuntimeEnvironment.application);
    radioButton1.setId(99);
    RadioButton radioButton2 = new RadioButton(RuntimeEnvironment.application);
    radioButton2.setId(100);
    RadioGroup radioGroup = new RadioGroup(RuntimeEnvironment.application);
    radioGroup.addView(radioButton1);
    radioGroup.addView(radioButton2);
    radioButton1.setChecked(true);
    assertThat(radioGroup.getCheckedRadioButtonId()).isEqualTo(radioButton1.getId());
    radioButton2.setChecked(true);
    assertThat(radioGroup.getCheckedRadioButtonId()).isEqualTo(radioButton2.getId());
}
Also used : RadioGroup(android.widget.RadioGroup) RadioButton(android.widget.RadioButton) Test(org.junit.Test)

Example 15 with RadioGroup

use of android.widget.RadioGroup in project robolectric by robolectric.

the class ShadowRadioGroupTest method check_shouldCallOnCheckedChangeListener.

@Test
public void check_shouldCallOnCheckedChangeListener() throws Exception {
    RadioGroup radioGroup = new RadioGroup(RuntimeEnvironment.application);
    TestOnCheckedChangeListener listener = new TestOnCheckedChangeListener();
    radioGroup.setOnCheckedChangeListener(listener);
    radioGroup.check(BUTTON_ID);
    assertEquals(Arrays.asList(BUTTON_ID), listener.onCheckedChangedCheckedIds);
    assertEquals(Arrays.asList(radioGroup), listener.onCheckedChangedGroups);
}
Also used : RadioGroup(android.widget.RadioGroup) Test(org.junit.Test)

Aggregations

RadioGroup (android.widget.RadioGroup)62 View (android.view.View)26 TextView (android.widget.TextView)19 RadioButton (android.widget.RadioButton)13 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)13 Button (android.widget.Button)9 CompoundButton (android.widget.CompoundButton)8 Validator (com.mobsandgeeks.saripaar.Validator)8 CheckBox (android.widget.CheckBox)5 IOException (java.io.IOException)5 RandomAccessFile (java.io.RandomAccessFile)5 Test (org.junit.Test)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 ImageView (android.widget.ImageView)4 ScrollView (android.widget.ScrollView)4 Paint (android.graphics.Paint)3 AlertDialog (android.support.v7.app.AlertDialog)3 LinearLayout (android.widget.LinearLayout)3 SeekBar (android.widget.SeekBar)3