Java Code Examples for android.widget.Button

The following are top voted examples for showing how to use android.widget.Button. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: nfc-smime   File: MainActivity.java View source code Vote up 8 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.LAX);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    fromText = (TextView) findViewById(R.id.from_text);
    toText = (EditText) findViewById(R.id.to_text);
    toText.setText(DEFAULT_RECIPIENT);
    subjectText = (EditText) findViewById(R.id.subject_text);
    bodyText = (EditText) findViewById(R.id.body_text);
    messageText = (TextView) findViewById(R.id.message);

    sendMailButton = (Button) findViewById(R.id.send_mail_button);
    sendMailButton.setOnClickListener(this);
    importPkcs12Button = (Button) findViewById(R.id.import_pkcs12_button);
    importPkcs12Button.setOnClickListener(this);
    nfcSignButton = (Button) findViewById(R.id.send_mail_nfc_button);
    nfcSignButton.setOnClickListener(this);
    nfcSignButton.setEnabled(false);

    adapter = NfcAdapter.getDefaultAdapter(this);

    pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
            getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    IntentFilter techDiscovered = new IntentFilter(
            NfcAdapter.ACTION_TECH_DISCOVERED);
    filters = new IntentFilter[] { techDiscovered };
    techLists = new String[][] { new String[] { IsoDep.class.getName() } };

    tryLoadFromKeyStore();
}
 
Example 2
Project: arduino-android   File: OpenAccessoryTest.java View source code Vote up 7 votes
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  mByteField = (EditText) findViewById(R.id.messagebyte);
  mResponseField = (EditText) findViewById(R.id.arduinoresponse);
  mSendButton = (Button) findViewById(R.id.sendButton);
  mSendButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      sendMessageToArduino();
    }
  });
  setupAccessory();
}
 
Example 3
Project: arduino-android   File: InputController.java View source code Vote up 7 votes
InputController(DroidTVActivity hostActivity) {
	super(hostActivity);
	Log.d("SRM", "constructor");
	mHostActivity = hostActivity;

	for (int i = 0; i < n; i++) {
		int buttonID = getResources().getIdentifier("button" + i, "id", hostActivity.getPackageName());
		Button button = (Button) findViewById(buttonID);
		button.setOnClickListener(this);
		button.setOnLongClickListener(this);
		
		String label = settings.getString("label"+i, "-");
		
		button.setText(label);
		button.setTag(new Integer(i));
	}
}
 
Example 4
Project: BioWiki   File: BlogPreferencesActivity.java View source code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blog_preferences);

    Integer id = getIntent().getIntExtra("id", -1);
    blog = BioWiki.getBlog(id);

    if (blog == null) {
        Toast.makeText(this, getString(R.string.blog_not_found), Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(StringUtils.unescapeHTML(blog.getBlogName()));
    actionBar.setDisplayHomeAsUpEnabled(true);

    mUsernameET = (EditText) findViewById(R.id.username);
    mPasswordET = (EditText) findViewById(R.id.password);
    mHttpUsernameET = (EditText) findViewById(R.id.httpuser);
    mHttpPasswordET = (EditText) findViewById(R.id.httppassword);
    mScaledImageWidthET = (EditText) findViewById(R.id.scaledImageWidth);
    mFullSizeCB = (CheckBox) findViewById(R.id.fullSizeImage);
    mScaledCB = (CheckBox) findViewById(R.id.scaledImage);
    mLocationCB = (CheckBox) findViewById(R.id.location);
    mImageWidthSpinner = (Spinner) findViewById(R.id.maxImageWidth);
    Button removeBlogButton = (Button) findViewById(R.id.remove_account);

    if (blog.isDotcomFlag()) {
        // Hide credentials section
        RelativeLayout credentialsRL = (RelativeLayout) findViewById(R.id.sectionContent);
        credentialsRL.setVisibility(View.GONE);
        removeBlogButton.setVisibility(View.GONE);
    }
    loadSettingsForBlog();
}
 
Example 5
Project: sw606f13   File: GameActivity.java View source code Vote up 7 votes
@SuppressWarnings("deprecation")
   public void addAndShowEndButton() {
	Button endButton = new Button(this);
	//endButton.setTextAppearance(this, R.style.ButtonFontStyle);
	endButton.setTextSize(44f);
	RelativeLayout.LayoutParams relaLayout = new RelativeLayout.LayoutParams(400, 150);
	relaLayout.setMargins(440, 150, 0, 0);
	endButton.setLayoutParams(relaLayout);
	endButton.setText("Godt gået!");
	
	
	endButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape));
	endButton.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			finish();
		}
	});
	RelativeLayout root =  (RelativeLayout)findViewById(id.RootLayout);
	root.addView(endButton);
}
 
Example 6
Project: androiddevice.info   File: MainActivity.java View source code Vote up 7 votes
private synchronized void submit() {
    LinearLayout alertLayout = (LinearLayout)LayoutInflater.from(MainActivity.this).inflate(R.layout.sending_alert,null);
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setCancelable(false).setView(alertLayout).setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    mAlertDialog = builder.show();
    //Button isn't null after show
    Button button = mAlertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    button.setBackgroundResource(R.drawable.black_background_state);
    button.setTextColor(MainActivity.this.getResources().getColor(android.R.color.white));

    if(hasBeenSubmitted()) {
        ((TextView)mAlertDialog.findViewById(android.R.id.text1)).setText(R.string.alreadySent);
        mAlertDialog.findViewById(R.id.sending_progressbar).setVisibility(View.GONE);
        button.setEnabled(true);
    } else {
        button.setEnabled(false);

        final JSONObject deviceInformation = DeviceInformation.getInstance().getDeviceInformation();
        if(null != mDeviceName && 0 != mDeviceName.length()) {
            try {
                deviceInformation.put("name", mDeviceName);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        RequestBody formBody = new FormEncodingBuilder().add("device", deviceInformation.toString()).build();
        Request request = new Request.Builder().url(getString(R.string.submit)).addHeader("User-Agent", "APP").post(formBody).build();
        client.newCall(request).enqueue(new HTTPCallback(this.getApplication()));
    }
}
 
Example 7
Project: ChangjieIME   File: CandidateView.java View source code Vote up 7 votes
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    
    result_max = Integer.parseInt(this.getResources().getString(R.string.result_max));
    this.wordList = new ArrayList<String>();
    this.setBackgroundColor(getResources().getColor(R.color.candidate_background));
    
    this.leftButton = (Button) findViewById(R.id.arrow_left);
    this.leftButton.setText("<");
    this.leftButton.setOnClickListener(new ButtonOnClickListener(this, 0));

    this.rightButton = (Button) findViewById(R.id.arrow_right);
    this.rightButton.setText(">");
    this.rightButton.setOnClickListener(new ButtonOnClickListener(this, 1));

    this.wordbuttonList = new ArrayList<Button>();
    this.wordbar = (LinearLayout)this.findViewById(R.id.wordbar);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1);

    for (int i = 0; i < result_max; i++) {
        Button b = new Button(ctx);
        b.setTextColor(this.getResources().getColor(R.color.candidate_normal));
        b.setTextSize(this.getResources().getDimension(R.dimen.candidates_char_size));
        b.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.button));
        this.wordbuttonList.add(b);
        this.wordbar.addView(b, lp);
        b.setOnClickListener(new WordButtonOnClickListener(this));

    }
    
    //this.bottombar = (LinearLayout)this.findViewById(R.id.bottombar);
    //this.inputBox = new ArrayList<ImageButton>();
    //for (int i = 0; i < 5; i++) {
    //    ImageButton b = new ImageButton(ctx);
    //    b.setImageResource(R.drawable.stroke0_show);
    //    b.setBackgroundColor(getResources().getColor(R.color.candidate_background));
    //    this.inputBox.add(b);
    //    this.bottombar.addView(b, lp);
    //}
    
}
 
Example 8
Project: Android_ShareSDK_Example_OAuth   File: OnekeyShare.java View source code Vote up 7 votes
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// container of the platform gridview
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
Example 9
Project: javainstaller   File: ChecklistAdapter.java View source code Vote up 7 votes
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
	this.id = position;
	LinearLayout ll = new LinearLayout(mcontext);
	ll.setOrientation(LinearLayout.VERTICAL);
	TextView tv = new TextView(mcontext);
	tv.setText(Html.fromHtml("<h2>"+List[position].text+"</h2>"+List[position].source+"<br>"+"path:"+List[position].getPath()+"<br>"+"source:"+List[position].getSource()));
	LinearLayout ll2 = new LinearLayout(mcontext);
	Button b = new Button(mcontext);
	b.setText("change path");
	b.setId(1);
	b.setOnClickListener(List[position]);
	if(position==0)b.setEnabled(false);
	Button b2 = new Button(mcontext);
	b2.setText("change source");
	b2.setId(2);
	b2.setOnClickListener(List[position]);
	ll2.addView(b);
	ll2.addView(b2);
	ll.addView(tv);
	ll.addView(ll2);
	Button b1 = new Button(mcontext);
	b1.setText((List[position].installed)?"uninstall":"install");
	b1.setId(0);
	b1.setOnClickListener(List[position]);
	if(Update.update[position]&&List[position].installed){
		TextView tv2 = new TextView(mcontext);
		tv2.setText(Update.updatetext[position]);
		LinearLayout ll3 = new LinearLayout(mcontext);
		Button b3 = new Button(mcontext);
		b3.setText("update");
		b3.setId(3);
		b3.setOnClickListener(List[position]);
		ll3.addView(b1);
		ll3.addView(b3);
		ll.addView(tv2);
		ll.addView(ll3);
	}
	else{
		ll.addView(b1);
	}
	ma.setContentView(ll);
	ma.state = 2;
}
 
Example 10
Project: dubsar_android   File: MainActivityTest.java View source code Vote up 7 votes
@UiThreadTest
public void testBackButton() {
	Model.addMock("/words/25441",
			"[25441,\"resourcefully\",\"adv\",\"\",[[34828,[],\"in a resourceful manner  \",\"adv.all\",null,0]],0]");

	Instrumentation instr = getInstrumentation();

	Button wotdWord = (Button)getActivity().findViewById(R.id.wotd_word);

	wotdWord.performClick();
	
	Button backButton = (Button)getActivity().findViewById(R.id.left_arrow);
	assertNotNull(backButton);
	backButton.performClick();
	
	// cheat?
	instr.callActivityOnResume(getActivity());
	
	Button fwdButton = (Button)getActivity().findViewById(R.id.right_arrow);
	assertNotNull(fwdButton);
	assertTrue(fwdButton.isEnabled());	
}
 
Example 11
Project: collect-mobile   File: FileAttributeComponent.java View source code Vote up 7 votes
private void setupRemoveButton() {
    Button button = (Button) inputView.findViewById(R.id.file_attribute_remove);
    if (imageFile.exists()) {
        button.setCompoundDrawablesWithIntrinsicBounds(new Attrs(context).drawable(R.attr.cameraIcon), null, null, null);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showRemoveDialog();
            }
        });
    } else {
        button.setVisibility(View.INVISIBLE);
    }
}
 
Example 12
Project: nou5   File: UpdaterActivity.java View source code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.updater_layout);

    //Variables assignment.
    textView_ProgressTextMessage = (TextView) findViewById(R.id.progressTextMessage);
    progress = (ProgressBar) findViewById(R.id.progressBar1);
    buttonAddNumber5 = (Button) findViewById(R.id.btnAddNumber5);
    buttonRemoveNumber5 = (Button) findViewById(R.id.btnRemoveNumber5);
    textView_titleUpdate = (TextView) findViewById(R.id.titleUpdate);

    //Declaring of custom font to objects.
    Typeface font_Kavoon = Typeface.createFromAsset(getAssets(), "fonts/Kavoon-Regular.otf");
    Typeface font_Pacifico = Typeface.createFromAsset(getAssets(), "fonts/Pacifico.ttf");
    Typeface font_Lobster = Typeface.createFromAsset(getAssets(), "fonts/Lobster.otf");

    //Applying custom font to objects.
    buttonAddNumber5.setTypeface(font_Pacifico);
    buttonRemoveNumber5.setTypeface(font_Pacifico);
    textView_titleUpdate.setTypeface(font_Lobster);
    textView_ProgressTextMessage.setTypeface(font_Kavoon);

    //set title text
    textView_titleUpdate.setText(" Manage Contacts");

}
 
Example 13
Project: TextSecureSMP   File: VerifyIdentityActivity.java View source code Vote up 7 votes
public void setResponderResultScreen(){
  setContentView(R.layout.verify_identity_activity_initiator);

  findViewById(R.id.Button3).setVisibility(View.INVISIBLE);

  Button button4 = (Button) findViewById(R.id.Button4);
  button4.setBackgroundColor(getRandomColour());
  button4.setEnabled(false);

  findViewById(R.id.Button5).setVisibility(View.INVISIBLE);
}
 
Example 14
Project: property-db   File: ScrollViewButtonsAndLabelsTest.java View source code Vote up 7 votes
@LargeTest
public void testArrowScrollDownOffScreenVerticalFadingEdge() {

    int offScreenIndex = findFirstButtonOffScreenTop2Bottom();
    Button firstButtonOffScreen = getActivity().getButton(offScreenIndex);

    for (int i = 0; i < offScreenIndex; i++) {
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
    }
    getInstrumentation().waitForIdleSync();
    assertTrue(firstButtonOffScreen.hasFocus());

    assertTrue("the button we've moved to off screen must not be the last "
            + "button in the scroll view for this test to work (since we "
            + "are expecting the fading edge to be there).",
            offScreenIndex < getActivity().getNumButtons());

    // now we are at the first button off screen
    int buttonLoc[] = {0, 0};
    firstButtonOffScreen.getLocationOnScreen(buttonLoc);
    int buttonBottom = buttonLoc[1] + firstButtonOffScreen.getHeight();

    int verticalFadingEdgeLength = mScrollView
            .getVerticalFadingEdgeLength();
    assertEquals("bottom of button should be verticalFadingEdgeLength "
            + "above the bottom of the screen",
            buttonBottom, mScreenBottom - verticalFadingEdgeLength);
}
 
Example 15
Project: Earmouse   File: ButtonGridFragment.java View source code Vote up 7 votes
/**
    * On view creation load any saved state and reconstruct the UI how we left it.
    */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_buttongrid, container, false);
	base = (LinearLayout) view.findViewById(R.id.grid_base);

       SharedPreferences settings = mCtx.getSharedPreferences(Main.PREFS_NAME, Activity.MODE_PRIVATE);
       Gson gson = new Gson();
       Type listType = new TypeToken<ArrayList<String>>() {}.getType();
       mAnswerList = gson.fromJson(settings.getString(PREFERENCES_MANSWERLIST, null), listType);
       listType = new TypeToken<ArrayList<Integer>>() {}.getType();
       mFadedButtonList = gson.fromJson(settings.getString(PREFERENCES_MFADEDBUTTONLIST, null), listType);
       if (mAnswerList != null)
           buildGrid();
       if (mFadedButtonList != null) {
           for (Integer i : mFadedButtonList) {
               Button b = (Button)tl.findViewById(i);
               if(b != null) {
                   b.setAlpha((float) 0.2);
                   b.setClickable(false);
               }
           }
       }

       return view;
}
 
Example 16
Project: MediaBrowser.Android   File: MbConnectActivity.java View source code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Always show debug logging during initial connection
    AppLogger.setDebugLoggingEnabled(true);

    setContentView(R.layout.activity_welcome2);
    findViewById(R.id.btnSignIn).setOnClickListener(onSignInClick);
    mConnectUserName = (EditText) findViewById(R.id.etUsername);
    mConnectPassword = (EditText) findViewById(R.id.etPassword);
    TextView linkText = (TextView) findViewById(R.id.tvParagraph1);
    linkText.requestFocus();
    linkText.setText(Html.fromHtml(getResources().getString(R.string.mb_connect_welcome_text_with_url)));
    linkText.setMovementMethod(LinkMovementMethod.getInstance());
    Button skip = (Button) findViewById(R.id.btnSkip);
    skip.setOnClickListener(onSkipClick);
    skip.requestFocus();
}
 
Example 17
Project: tooltip   File: ButtonsActivity.java View source code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_buttons);

    // Add a few buttons
    LinearLayout container = (LinearLayout)findViewById(R.id.container);
    for(int i = 0; i < 5; i++) {
        LinearLayout row = new LinearLayout(this);
        row.setOrientation(LinearLayout.VERTICAL);
        container.addView(row);

        LinearLayout.LayoutParams rowParams = (LinearLayout.LayoutParams)row.getLayoutParams();
        rowParams.width = 0;
        rowParams.weight = 1;

        for(int j = 0; j < 5; j++) {
            Button button = (Button)getLayoutInflater().inflate(R.layout.button, row, false);
            row.addView(button);

            LinearLayout.LayoutParams buttonParams = (LinearLayout.LayoutParams)button.getLayoutParams();
            buttonParams.height = 0;
            buttonParams.weight = 1;
        }
    }
}
 
Example 18
Project: OpenAlprDroidApp   File: MainActivity.java View source code Vote up 7 votes
private void setBtnListenerOrDisable(
        Button btn,
        Button.OnClickListener onClickListener,
        String intentName
) {
    if (isIntentAvailable(this, intentName)) {
        btn.setOnClickListener(onClickListener);
    }
}
 
Example 19
Project: viaja-facil   File: ViajaFacilActivity.java View source code Vote up 7 votes
@Override
public Object onRetainNonConfigurationInstance() {
	Button btnResults = (Button) findViewById(R.id.btnResults);
	Button btnSearch = (Button) findViewById(R.id.btnSearch);
    final StoredData toStore = new StoredData(markers.getFromPos(), markers.getToPos(), mapView.getMapCenter(), mapView.getZoomLevel(), SearchResultHolder.getInstance().getResultList(), resultOverlays, useSubte, useTrains, searchmode, mlkSet1, mlkSet2, btnResults.isEnabled(), btnSearch.getText(), lastGeocodedAddr);
    return toStore;
}
 
Example 20
Project: processing-shellmaker   File: ShellLayout.java View source code Vote up 7 votes
public void createButton(Context context) {

            button = new Button(context);

            button.setId(id);
            button.setTextSize(24.0f);
            button.setBackgroundColor(normalBackColor);
            button.setTextColor(normalTextColor);

            final Integer X1 = 130;
            final Integer X2 = X1 * 2;
            final Integer MARGIN = 10;

            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            lp.setMargins(MARGIN, MARGIN, MARGIN, MARGIN);
            button.setLayoutParams(lp);

            switch (dimension) {
                case ONE_BY_ONE:
                    button.setWidth(X1);
                    button.setHeight(X1);
                    button.setText("1x1");
                    break;
                case ONE_BY_TWO:
                    button.setWidth(X1);
                    button.setHeight(X2);
                    button.setText("1x2");
                    break;
                case TWO_BY_ONE:
                    button.setWidth(X2);
                    button.setHeight(X1);
                    button.setText("2x1");
                    break;
                case TWO_BY_TWO:
                    button.setWidth(X2);
                    button.setHeight(X2);
                    button.setText("2x2");
                    break;
            }
        }
 
Example 21
Project: chbosync4android   File: AndroidHomeScreen.java View source code Vote up 7 votes
private void setMultiButtonsLayout() {
    // Set the content view
    setContentView(R.layout.homescreen);

    // Grab the views 
    mainLayout = (LinearLayout)findViewById(R.id.mainLayout);
    linLayoutForButtons = (LinearLayout)findViewById(R.id.buttons);
    syncAllButton = (Button)findViewById(R.id.syncAllButton);

    // Add the sync all button if required
    if (syncAllText != null) {
        syncAllButton.setFocusable(false);
        syncAllButton.setText(syncAllText);
        SyncAllButtonListener buttonListener = new SyncAllButtonListener();
        syncAllButton.setOnClickListener(buttonListener);
    } else {
        // Remove the button bar
        LinearLayout buttonBar = (LinearLayout)findViewById(R.id.homeScreenButtonBar);
        mainLayout.removeView(buttonBar);
    }
}
 
Example 22
Project: Earmouse   File: ButtonGridFragment.java View source code Vote up 7 votes
/**
 * Constructs a grid of Button objects from the mAnswerlist field.
 */
private void buildGrid() {
    tl = new TableLayout(mCtx);
    tl.setStretchAllColumns(true);
    tl.setShrinkAllColumns(true);
    base.addView(tl, new TableLayout.LayoutParams());
    TableRow tr = null;
    if(mAnswerList == null)
        return;

    for(int i = 0;i < mAnswerList.size(); i++) {
        if(i % COLUMNS == 0) {
            tr = new TableRow(mCtx);
            tl.addView(tr);
        }
        Button b = new Button(mCtx);
        b.setTextAppearance(mCtx , R.style.GridButtonStyle);
        b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT));
        b.setWidth(0);
        b.setText(mAnswerList.get(i));
        b.setId(i);
        b.setOnClickListener(new GridButtonClickListener(i));
        b.setBackground(getActivity().getResources().getDrawable(R.drawable.btn_default_holo_dark));
        if (tr != null) {
            tr.addView(b);
        }
    }
}
 
Example 23
Project: wear_AdvancedSettings   File: DonateActivity.java View source code Vote up 7 votes
@Override
public void onClick(View v) {
    Button button = (Button) v;
    button.getId();
    Uri uri;
    Intent intent;
    switch (button.getId()) {
        case (R.id.regular):
            uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6J9K4Y42PT3ZE");
            intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            break;
        case (R.id.great):
            uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7C7EL6ENPJ2NU");
            intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            break;
        case (R.id.giant):
            uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DU9MXS8HEQE6G");
            intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            break;
        case (R.id.btc):
            uri = Uri.parse("http://sssemil.github.io/Donate/btc.html");
            intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            break;
        default:
            break;
    }
}
 
Example 24
Project: ohmagePhone   File: FilterControl.java View source code Vote up 7 votes
/**
 * Constructs the parts of the control that provide actual functionality. Declarative styling is handled by initStyles().
 * @param context the context of whoever's creating this control, usually passed into the class constructor
 */
protected void initControl(Context context) {
	LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
	this.setLayoutParams(params);
	this.setOrientation(HORIZONTAL);
	this.setBackgroundResource(R.color.lightergray);
	
	// load up the elements of the actionbar from controls_filter.xml
	LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	inflater.inflate(R.layout.controls_filter, this, true);
	
	// and init an empty list so we don't crash and burn when we try to read before populating
	mItemList = new ArrayList<Pair<String,String>>();
	mSelectionIndex = 0;
	
	mPrevBtn = (Button) findViewById(R.id.controls_filter_prev);
	mCurrentBtn = (Button) findViewById(R.id.controls_filter_current);
	mNextBtn = (Button) findViewById(R.id.controls_filter_next);
	
	FilterClickHandler handler = new FilterClickHandler();
	
	mPrevBtn.setOnClickListener(handler);
	mCurrentBtn.setOnClickListener(handler);
	mNextBtn.setOnClickListener(handler);
	
	mCurrentBtn.setSelected(true);
}
 
Example 25
Project: android-galaxyzoo   File: QuestionFragment.java View source code Vote up 7 votes
private Button createAnswerButton(final Activity activity, final DecisionTree.Answer answer) {
    final LayoutInflater inflater = LayoutInflater.from(activity);
    final Button button = (Button)inflater.inflate(R.layout.question_answer_button, null);
    button.setText(answer.getText());

    final BitmapDrawable icon = getIcon(activity, answer);
    button.setCompoundDrawables(null, icon, null, null);
    //There is still some padding: button.setCompoundDrawablePadding(0); //UiUtils.getPxForDpResource(activity, R.dimen.standard_margin));
    return button;
}
 
Example 26
Project: collect-mobile   File: CodeAttributeComponent.java View source code Vote up 7 votes
private void includeDescriptionsButton() {
    View inputView = toInputView();
    ViewGroup parent = (ViewGroup) inputView.getParent();
    if (parent == null)
        return;
    if (parent.findViewWithTag(DESCRIPTION_BUTTON_TAG) == null) {
        Button button = new Button(context);
        button.setTextAppearance(context, android.R.style.TextAppearance_Small);
        button.setTag(DESCRIPTION_BUTTON_TAG);
        button.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        button.setText(context.getResources().getString(R.string.label_show_code_descriptions));
        button.setBackgroundDrawable(null);
        button.setPaintFlags(button.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                CodeListDescriptionDialogFragment.show(context.getSupportFragmentManager());
            }
        });
        int linkColor = new TextView(context).getLinkTextColors().getDefaultColor();
        button.setTextColor(linkColor);
        parent.addView(button);
    }
}
 
Example 27
Project: ohmagePhone   File: LocTrigAddLocBalloon.java View source code Vote up 7 votes
public void show(GeoPoint gp, String action, String addr) { 
	
	if(mVisible) {
		hide();
	}
	
	mLocGP = gp;
	mVisible = true;
	
	Button button = (Button) mLayout.findViewById(R.id.balloon_add_loc);
	button.setOnClickListener(this);
	//Set the given text to the button
	button.setText(action);
	button.setHeight(mMapView.getHeight() / 2 - 10);
	button.invalidate();
    
	TextView tv = (TextView) mLayout.findViewById(R.id.balloon_address);
	tv.setTextColor(Color.WHITE);
	
	mMapView.getController().animateTo(gp);
	//Add the view to the map
	mMapView.addView(mLayout, 
    		   new MapView.LayoutParams(
    		   Math.min(mMapView.getWidth() - 20, MAX_W),
    		   Math.min(mMapView.getHeight() / 2 - 10, MAX_H), gp, 
    		   MapView.LayoutParams.BOTTOM_CENTER));
    
	//If no address passed, fetch the address
	if(addr.equals("")) {
		tv.setText(R.string.trigger_loc_loading_address);
		ProgressBar pb = (ProgressBar) mLayout.findViewById(R.id.balloon_progress);
		pb.setVisibility(ProgressBar.VISIBLE);
			
		//Fetch the address in background
		new FetchAddressTask().execute(mLocGP);
	}
	else {
		//Address provided as argument, simply display it
		onAddressFetched(addr);
	}
}
 
Example 28
Project: property-db   File: OneEditTextActivityNotSelected.java View source code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    mRootView = new ScrollView(this);

    EditText editText = new EditText(this);
    Button button = new Button(this);
    button.setText("The focus is here.");
    button.setFocusableInTouchMode(true);
    button.requestFocus();
    mDefaultFocusedView = button;
    layout.addView(button);
    layout.addView(editText);

    ((ScrollView) mRootView).addView(layout);
    setContentView(mRootView);
}
 
Example 29
Project: travelinfo   File: SplashActivity.java View source code Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_splash);
	
	AppConnect.getInstance("3a0bf7dd24f36940eecb5a2f2a48c82f", "baidu", this);
	
	
	btnLogin = (Button) findViewById(R.id.btn_login);
	etTest = (EditText) findViewById(R.id.editText1);
	mAuthInfo = new AuthInfo(this, Constants.APP_KEY,
			Constants.REDIRECT_URL, Constants.SCOPE);
	mSsoHandler = new SsoHandler(SplashActivity.this, mAuthInfo);
	
	btnLogin.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			
			mSsoHandler.authorize(new AuthDialogListener());
		}
	});

       mAccessToken = AccessTokenKeeper.readAccessToken(this);
	if (mAccessToken.isSessionValid()) {
		String date = new java.text.SimpleDateFormat("yyyy/MM/dd hh:mm:ss")
				.format(new java.util.Date(mAccessToken.getExpiresTime()));
		btnLogin.setVisibility(View.GONE);
		mHandler.sendEmptyMessageDelayed(0, 1000);
	} else {
		btnLogin.setVisibility(View.VISIBLE);
		Animation alphaAnimation = AnimationUtils.loadAnimation(this,
				R.anim.anim_alpha2);
		btnLogin.startAnimation(alphaAnimation);
	}

}
 
Example 30
Project: topodroid   File: OverviewActivity.java View source code Vote up 7 votes
private Button makeButton( String text )
{
  Button myTextView = new Button( this );
  myTextView.setHeight( 42 );

  myTextView.setText( text );
  myTextView.setTextColor( 0xffffffff );
  myTextView.setTextSize( TypedValue.COMPLEX_UNIT_DIP, 16 );
  myTextView.setBackgroundColor( 0xff333333 );
  myTextView.setSingleLine( true );
  myTextView.setGravity( 0x03 ); // left
  myTextView.setPadding( 4, 4, 4, 4 );
  // Log.v(TopoDroidApp.TAG, "makeButton " + text );
  return myTextView;
}
 
Example 31
Project: sawan-bar   File: InCallTouchUi.java View source code Vote up 6 votes
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    if (DBG) log("InCallTouchUi onFinishInflate(this = " + this + ")...");

    // Look up the various UI elements.

    // "Dial-to-answer" widget for incoming calls.
    mIncomingCallWidget = (SlidingTab) findViewById(R.id.incomingCallWidget);
    mIncomingCallWidget.setLeftTabResources(
            R.drawable.ic_jog_dial_answer,
            com.android.internal.R.drawable.jog_tab_target_green,
            com.android.internal.R.drawable.jog_tab_bar_left_answer,
            com.android.internal.R.drawable.jog_tab_left_answer
            );
    mIncomingCallWidget.setRightTabResources(
            R.drawable.ic_jog_dial_decline,
            com.android.internal.R.drawable.jog_tab_target_red,
            com.android.internal.R.drawable.jog_tab_bar_right_decline,
            com.android.internal.R.drawable.jog_tab_right_decline
            );

    // For now, we only need to show two states: answer and decline.
    mIncomingCallWidget.setLeftHintText(R.string.slide_to_answer_hint);
    mIncomingCallWidget.setRightHintText(R.string.slide_to_decline_hint);

    mIncomingCallWidget.setOnTriggerListener(this);

    // Container for the UI elements shown while on a regular call.
    mInCallControls = findViewById(R.id.inCallControls);

    // Regular (single-tap) buttons, where we listen for click events:
    // Main cluster of buttons:
    mAddButton = (Button) mInCallControls.findViewById(R.id.addButton);
    mAddButton.setOnClickListener(this);
    mMergeButton = (Button) mInCallControls.findViewById(R.id.mergeButton);
    mMergeButton.setOnClickListener(this);
    mEndButton = (Button) mInCallControls.findViewById(R.id.endButton);
    mEndButton.setOnClickListener(this);
    mDialpadButton = (Button) mInCallControls.findViewById(R.id.dialpadButton);
    mDialpadButton.setOnClickListener(this);
    mBluetoothButton = (ToggleButton) mInCallControls.findViewById(R.id.bluetoothButton);
    mBluetoothButton.setOnClickListener(this);
    mMuteButton = (ToggleButton) mInCallControls.findViewById(R.id.muteButton);
    mMuteButton.setOnClickListener(this);
    mSpeakerButton = (ToggleButton) mInCallControls.findViewById(R.id.speakerButton);
    mSpeakerButton.setOnClickListener(this);

    // Upper corner buttons:
    mHoldButtonContainer = mInCallControls.findViewById(R.id.holdButtonContainer);
    mHoldButton = (ImageButton) mInCallControls.findViewById(R.id.holdButton);
    mHoldButton.setOnClickListener(this);
    mHoldButtonLabel = (TextView) mInCallControls.findViewById(R.id.holdButtonLabel);
    //
    mSwapButtonContainer = mInCallControls.findViewById(R.id.swapButtonContainer);
    mSwapButton = (ImageButton) mInCallControls.findViewById(R.id.swapButton);
    mSwapButton.setOnClickListener(this);
    mSwapButtonLabel = (TextView) mInCallControls.findViewById(R.id.swapButtonLabel);
    if (PhoneApp.getPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA) {
        // In CDMA we use a generalized text - "Manage call", as behavior on selecting
        // this option depends entirely on what the current call state is.
        mSwapButtonLabel.setText(R.string.onscreenManageCallsText);
    } else {
        mSwapButtonLabel.setText(R.string.onscreenSwapCallsText);
    }
    //
    mCdmaMergeButtonContainer = mInCallControls.findViewById(R.id.cdmaMergeButtonContainer);
    mCdmaMergeButton = (ImageButton) mInCallControls.findViewById(R.id.cdmaMergeButton);
    mCdmaMergeButton.setOnClickListener(this);

    // Add a custom OnTouchListener to manually shrink the "hit
    // target" of some buttons.
    // (We do this for a few specific buttons which are vulnerable to
    // "false touches" because either (1) they're near the edge of the
    // screen and might be unintentionally touched while holding the
    // device in your hand, or (2) they're in the upper corners and might
    // be touched by the user's ear before the prox sensor has a chance to
    // kick in.)
    View.OnTouchListener smallerHitTargetTouchListener = new SmallerHitTargetTouchListener();
    mAddButton.setOnTouchListener(smallerHitTargetTouchListener);
    mMergeButton.setOnTouchListener(smallerHitTargetTouchListener);
    mDialpadButton.setOnTouchListener(smallerHitTargetTouchListener);
    mBluetoothButton.setOnTouchListener(smallerHitTargetTouchListener);
    mSpeakerButton.setOnTouchListener(smallerHitTargetTouchListener);
    mHoldButton.setOnTouchListener(smallerHitTargetTouchListener);
    mSwapButton.setOnTouchListener(smallerHitTargetTouchListener);
    mCdmaMergeButton.setOnTouchListener(smallerHitTargetTouchListener);
    mSpeakerButton.setOnTouchListener(smallerHitTargetTouchListener);

    // Icons we need to change dynamically.  (Most other icons are specified
    // directly in incall_touch_ui.xml.)
    mHoldIcon = getResources().getDrawable(R.drawable.ic_in_call_touch_round_hold);
    mUnholdIcon = getResources().getDrawable(R.drawable.ic_in_call_touch_round_unhold);
    mShowDialpadIcon = getResources().getDrawable(R.drawable.ic_in_call_touch_dialpad);
    mHideDialpadIcon = getResources().getDrawable(R.drawable.ic_in_call_touch_dialpad_close);
}
 
Example 32
Project: TestingStaff   File: DetailActivity.java View source code Vote up 6 votes
private void setupDetailSubtitle(LinearLayout layout) {
	if (subtitleList != null) {
		if (subtitleList.size() == 0) {
			return;
		}

		for (int i = 0; i < subtitleList.size(); i+=2) {
			//Create relative layout including both labels
			LinearLayout subtitleLayout = new LinearLayout(this);
			subtitleLayout.setOrientation(LinearLayout.HORIZONTAL);
			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(Math.round(DataUtil.dip2px(this, 280)), LinearLayout.LayoutParams.WRAP_CONTENT);
			layoutParams.setMargins(0, Math.round(DataUtil.dip2px(this, 10)), 0, 0);
			layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
			layout.addView(subtitleLayout, layoutParams);

			// Create label 0
			TextView subtitleTextView = new TextView(this);
			subtitleTextView.setTextColor(getResources().getColor(R.color.Fancl_Blue));
			subtitleTextView.setTextSize(currentTextSize);
			subtitleTextView.setText(subtitleList.get(i));

			LinearLayout.LayoutParams subtitleTextViewLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
			subtitleLayout.addView(subtitleTextView, subtitleTextViewLayoutParams);

			// Create label 1
			TextView valueTextView = new TextView(this);
			valueTextView.setTextColor(getResources().getColor(R.color.Fancl_Blue));
			valueTextView.setTextSize(currentTextSize);
			valueTextView.setText(subtitleList.get(i+1));

			LinearLayout.LayoutParams valueTextViewLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
			valueTextViewLayoutParams.setMargins(Math.round(DataUtil.dip2px(this, 10)), 0, 0, 0);
			subtitleLayout.addView(valueTextView, valueTextViewLayoutParams);
		}

		if (couponStatus.equals("iCoupon")) {
			// create a redeem button and align to right hand side
			Button redeemButton = new Button(this);
			redeemButton.setText(R.string.promotion_detail_redeem_btn_title);
			redeemButton.setTextColor(Color.WHITE);
			redeemButton.setGravity(Gravity.CENTER);
			redeemButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_redeem));
			
			redeemButton.setOnClickListener(new OnClickListener(){  
	            public void onClick(View v) {  
	            	Intent intent = new Intent(DetailActivity.this, PurchaseQRCodeScanActivity.class);
					startActivity(intent);
	  
	            } 
			});
	          

			LinearLayout.LayoutParams redeemLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
			redeemLayoutParams.setMargins(0, Math.round(DataUtil.dip2px(this, 5)), Math.round(DataUtil.dip2px(this, 10)), 0);
			redeemLayoutParams.gravity = Gravity.RIGHT;
			layout.addView(redeemButton, redeemLayoutParams);
		}
	}
}
 
Example 33
Project: myrom_frameworks_policies   File: PowerDialog.java View source code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Context context = getContext();

    if (sStatusBar == null) {
        sStatusBar = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
    }

    setContentView(com.android.internal.R.layout.power_dialog);

    getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
            WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

    setTitle(context.getText(R.string.power_dialog));

    mKeyguard = (Button) findViewById(R.id.keyguard);
    mPower = (Button) findViewById(R.id.off);
    mRadioPower = (Button) findViewById(R.id.radio_power);
    mSilent = (Button) findViewById(R.id.silent);

    if (mKeyguard != null) {
        mKeyguard.setOnKeyListener(this);
        mKeyguard.setOnClickListener(this);
    }
    if (mPower != null) {
        mPower.setOnClickListener(this);
    }
    if (mRadioPower != null) {
        mRadioPower.setOnClickListener(this);
    }
    if (mSilent != null) {
        mSilent.setOnClickListener(this);
        // XXX: HACK for now hide the silent until we get mute support
        mSilent.setVisibility(View.GONE);
    }

    CharSequence text;

    // set the keyguard button's text
    text = context.getText(R.string.screen_lock);
    mKeyguard.setText(text);
    mKeyguard.requestFocus();

    try {
        ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
        if (phone != null) {
            text = phone.isRadioOn() ? context
                    .getText(R.string.turn_off_radio) : context
                    .getText(R.string.turn_on_radio);
        }
    } catch (RemoteException ex) {
        // ignore it
    }

    mRadioPower.setText(text);
}