Search in sources :

Example 36 with ToggleButton

use of android.widget.ToggleButton in project remote-desktop-clients by iiordanov.

the class aSPICE method onCreate.

@Override
public void onCreate(Bundle icicle) {
    layoutID = R.layout.main_spice;
    super.onCreate(icicle);
    ipText = (EditText) findViewById(R.id.textIP);
    sshServer = (EditText) findViewById(R.id.sshServer);
    sshPort = (EditText) findViewById(R.id.sshPort);
    sshUser = (EditText) findViewById(R.id.sshUser);
    sshPassword = (EditText) findViewById(R.id.sshPassword);
    sshPassphrase = (EditText) findViewById(R.id.sshPassphrase);
    sshCredentials = (LinearLayout) findViewById(R.id.sshCredentials);
    sshCaption = (TextView) findViewById(R.id.sshCaption);
    layoutUseSshPubkey = (LinearLayout) findViewById(R.id.layoutUseSshPubkey);
    sshServerEntry = (LinearLayout) findViewById(R.id.sshServerEntry);
    portText = (EditText) findViewById(R.id.textPORT);
    tlsPort = (EditText) findViewById(R.id.tlsPort);
    passwordText = (EditText) findViewById(R.id.textPASSWORD);
    textNickname = (EditText) findViewById(R.id.textNickname);
    buttonImportCa = (Button) findViewById(R.id.buttonImportCa);
    buttonImportCa.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            aSPICE.this.updateSelectedFromView();
            showDialog(R.layout.import_tls_ca_dialog);
        }
    });
    // Here we say what happens when the Pubkey Checkbox is
    // checked/unchecked.
    checkboxUseSshPubkey = (CheckBox) findViewById(R.id.checkboxUseSshPubkey);
    // Define what happens when somebody selects different VNC connection
    // types.
    connectionType = (Spinner) findViewById(R.id.connectionType);
    connectionType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> ad, View view, int itemIndex, long id) {
            selectedConnType = itemIndex;
            if (selectedConnType == Constants.CONN_TYPE_PLAIN) {
                setVisibilityOfSshWidgets(View.GONE);
            } else if (selectedConnType == Constants.CONN_TYPE_SSH) {
                setVisibilityOfSshWidgets(View.VISIBLE);
                if (ipText.getText().toString().equals(""))
                    ipText.setText("localhost");
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> ad) {
        }
    });
    checkboxKeepPassword = (CheckBox) findViewById(R.id.checkboxKeepPassword);
    checkboxUseDpadAsArrows = (CheckBox) findViewById(R.id.checkboxUseDpadAsArrows);
    checkboxRotateDpad = (CheckBox) findViewById(R.id.checkboxRotateDpad);
    checkboxLocalCursor = (CheckBox) findViewById(R.id.checkboxUseLocalCursor);
    checkboxEnableSound = (CheckBox) findViewById(R.id.checkboxEnableSound);
    goButton = (Button) findViewById(R.id.buttonGO);
    goButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (ipText.getText().length() != 0 && (portText.getText().length() != 0 || tlsPort.getText().length() != 0))
                canvasStart();
            else
                Toast.makeText(view.getContext(), R.string.spice_server_empty, Toast.LENGTH_LONG).show();
        }
    });
    // The advanced settings button.
    toggleAdvancedSettings = (ToggleButton) findViewById(R.id.toggleAdvancedSettings);
    layoutAdvancedSettings = (LinearLayout) findViewById(R.id.layoutAdvancedSettings);
    toggleAdvancedSettings.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean checked) {
            if (checked)
                layoutAdvancedSettings.setVisibility(View.VISIBLE);
            else
                layoutAdvancedSettings.setVisibility(View.GONE);
        }
    });
    // The geometry type and dimensions boxes.
    spinnerGeometry = (Spinner) findViewById(R.id.spinnerRdpGeometry);
    resWidth = (EditText) findViewById(R.id.rdpWidth);
    resHeight = (EditText) findViewById(R.id.rdpHeight);
    spinnerGeometry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View view, int itemIndex, long id) {
            selected.setRdpResType(itemIndex);
            setRemoteWidthAndHeight();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    // Define what happens when the Import/Export button is pressed.
    ((Button) findViewById(R.id.buttonImportExport)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.util.Log.e(TAG, "import/export!!");
            showDialog(R.layout.importexport);
        }
    });
    // Load list of items from asset folder and populate
    try {
        spinnerArray = listFiles("layouts");
    } catch (IOException e) {
        e.printStackTrace();
    }
    layoutMapSpinner = (Spinner) findViewById(R.id.layoutMaps);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    layoutMapSpinner.setAdapter(adapter);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) IOException(java.io.IOException) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter)

Example 37 with ToggleButton

use of android.widget.ToggleButton in project mobile-android by photo.

the class FeatherActivity method hideInfoScreen.

/**
 * Hide info screen.
 */
private void hideInfoScreen() {
    createInfoScreenAnimations(false);
    mViewFlipper.setDisplayedChild(0);
    View convertView = mWorkspace.getChildAt(mWorkspace.getChildCount() - 1);
    if (null != convertView) {
        View button = convertView.findViewById(R.id.tool_image);
        if (button != null && button instanceof ToggleButton) {
            ((ToggleButton) button).setChecked(false);
        }
    }
}
Also used : ToggleButton(android.widget.ToggleButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ToolbarView(com.aviary.android.feather.widget.ToolbarView)

Example 38 with ToggleButton

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

the class ToggleButtonActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Get references to a background containers
    final FrameLayout top = findViewById(R.id.top_frame);
    final FrameLayout bottom = findViewById(R.id.bottom_frame);
    // Get a reference to the ToggleButton
    final ToggleButton toggleButton = findViewById(R.id.togglebutton);
    // Set an setOnCheckedChangeListener on the ToggleButton
    setListener(toggleButton, top);
    // Get a reference to the Switch
    final Switch switcher = findViewById(R.id.switcher);
    // Set an OnCheckedChangeListener on the Switch
    setListener(switcher, bottom);
}
Also used : ToggleButton(android.widget.ToggleButton) Switch(android.widget.Switch) FrameLayout(android.widget.FrameLayout)

Example 39 with ToggleButton

use of android.widget.ToggleButton in project JustAndroid by chinaltz.

the class AbExpandTabView method setData.

/**
 * 设置tab item默认标题和内容View
 */
public void setData(List<String> tabTexts, List<View> contentViews) {
    for (int i = 0; i < contentViews.size(); i++) {
        View view = contentViews.get(i);
        int maxHeight = (int) (displayHeight * 0.6);
        RelativeLayout parentLayout = new RelativeLayout(context);
        parentLayout.setBackgroundColor(Color.parseColor("#b0000000"));
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, maxHeight);
        layoutParams.leftMargin = 0;
        layoutParams.rightMargin = 0;
        parentLayout.addView(view, layoutParams);
        tabContentViews.add(parentLayout);
        final ToggleButton tabButton = new ToggleButton(context);
        tabButton.setGravity(Gravity.CENTER);
        tabButton.setTextOn(null);
        tabButton.setTextOff(null);
        tabButton.setBackgroundResource(R.drawable.bg_tab_button);
        tabButton.setTextColor(context.getResources().getColor(R.color.gray_content));
        tabButton.setSingleLine(true);
        // 默认标题
        tabButton.setText(tabTexts.get(i));
        AbViewUtil.setTextSize(tabButton, 28);
        addView(tabButton, new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
        View line = new View(context);
        line.setBackgroundResource(R.color.gray_line);
        LayoutParams layoutParamsLine = new LayoutParams(1, LayoutParams.MATCH_PARENT);
        layoutParamsLine.setMargins(0, 5, 0, 5);
        if (i < contentViews.size() - 1) {
            addView(line, layoutParamsLine);
        }
        // 添加到列表
        tabButtons.add(tabButton);
        // 用于判断位置
        tabButton.setTag(i);
        tabButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (popupWindow == null || !popupWindow.isShowing()) {
                    currentTabButton = tabButton;
                    currentPosition = (Integer) currentTabButton.getTag();
                    showPopup(currentPosition);
                } else {
                    dismissPopup();
                }
            }
        });
        tabButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (onCheckedChangedListener != null) {
                    onCheckedChangedListener.onCheckedChanged(currentPosition, isChecked);
                }
            }
        });
    }
}
Also used : ToggleButton(android.widget.ToggleButton) RelativeLayout(android.widget.RelativeLayout) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Example 40 with ToggleButton

use of android.widget.ToggleButton in project butterknife by JakeWharton.

the class OnCheckedChangedTest method argumentCast.

@UiThreadTest
@Test
public void argumentCast() {
    class MyView extends ToggleButton implements ArgumentCast.MyInterface {

        MyView(Context context) {
            super(context);
        }
    }
    View view1 = new MyView(InstrumentationRegistry.getContext());
    view1.setId(1);
    View view2 = new MyView(InstrumentationRegistry.getContext());
    view2.setId(2);
    View view3 = new MyView(InstrumentationRegistry.getContext());
    view3.setId(3);
    ViewGroup tree = new FrameLayout(InstrumentationRegistry.getContext());
    tree.addView(view1);
    tree.addView(view2);
    tree.addView(view3);
    ArgumentCast target = new ArgumentCast();
    ButterKnife.bind(target, tree);
    view1.performClick();
    assertSame(view1, target.last);
    view2.performClick();
    assertSame(view2, target.last);
    view3.performClick();
    assertSame(view3, target.last);
}
Also used : Context(android.content.Context) ToggleButton(android.widget.ToggleButton) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

ToggleButton (android.widget.ToggleButton)48 View (android.view.View)21 TextView (android.widget.TextView)21 ImageView (android.widget.ImageView)13 Button (android.widget.Button)11 SeekBar (android.widget.SeekBar)10 CompoundButton (android.widget.CompoundButton)9 AdapterView (android.widget.AdapterView)7 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)6 ViewGroup (android.view.ViewGroup)5 ListView (android.widget.ListView)4 SuppressLint (android.annotation.SuppressLint)3 CheckBox (android.widget.CheckBox)3 EditText (android.widget.EditText)3 LinearLayout (android.widget.LinearLayout)3 RadioButton (android.widget.RadioButton)3 Context (android.content.Context)2 KeyEvent (android.view.KeyEvent)2 OnClickListener (android.view.View.OnClickListener)2 ArrayAdapter (android.widget.ArrayAdapter)2