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 generate more good examples.
Example 1
Project: GongXianSheng   File: RunwiseDialog.java   View source code 7 votes vote down vote up
@Inject
public RunwiseDialog(@ActivityContext Context context) {
	super(context, R.style.CustomProgressDialog);
	setContentView(R.layout.dialog_layout);
	Window window = getWindow();
	window.getAttributes().gravity = Gravity.CENTER;
		window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	this.setCancelable(true);
	this.setCanceledOnTouchOutside(false);
	this.context = (TextView) this.findViewById(R.id.context);
       cancle = (Button) this.findViewById(R.id.cancle);
	okBtn = (Button) this.findViewById(R.id.ok);
	vLine = this.findViewById(R.id.vline);
	hLine = this.findViewById(R.id.hline);
	title = (TextView) this.findViewById(R.id.title);
	btnLayout = (LinearLayout) this.findViewById(R.id.dialog_btn_layout);
	setLeftBtnListener("取消",null);
}
 
Example 2
Project: GitHub   File: HWAdatper.java   View source code 7 votes vote down vote up
@Override
protected void convert(BaseViewHolder viewHolder, final Wares wares) {
    SimpleDraweeView draweeView = (SimpleDraweeView) viewHolder.getView(R.id.drawee_view);
    draweeView.setImageURI(Uri.parse(wares.getImgUrl()));

    viewHolder.getTextView(R.id.text_title).setText(wares.getName());
    viewHolder.getTextView(R.id.text_price).setText("¥ "+wares.getPrice());

    Button button =viewHolder.getButton(R.id.btn_add);
    if(button !=null) {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                provider.put(wares);

                ToastUtils.show(context, "已添加到购物车");
            }
        });
    }

}
 
Example 3
Project: scab   File: InfoFromFacebookActivity.java   View source code 7 votes vote down vote up
@Override
        public void onSuccess(com.facebook.login.LoginResult loginResult) {
            Profile facebookProfile = Profile.getCurrentProfile();
            if (facebookProfile == null) {
                String errorMsg = InfoFromFacebookActivity.this.getResources().getString(R.string.facebook_error);
                errorMsg = errorMsg + ".";
                Snackbar.make(textViewFacebookName, errorMsg, Snackbar.LENGTH_LONG).show();
                textViewFacebookName.setText(errorMsg);
            } else {
                facebookProfilePhoto.setProfileId(facebookProfile.getId());
                textViewFacebookName.setText(facebookProfile.getName());

                buttonAck.setEnabled(true);
                buttonSwitch.setVisibility(Button.VISIBLE);
            }

            // TODO: Do not store access token - it is a security issue storing this
            // TODO and appears to be of no benefit.
//                AccessToken token = loginResult.getAccessToken();
//                DataHolder data = DataHolder.getInstance(InfoFromFacebookActivity.this.getApplicationContext());
//                data.setFacebookToken(token.getToken());
//                data.persist();
        }
 
Example 4
Project: ulogger-android   File: MainActivity.java   View source code 6 votes vote down vote up
/**
 * Display About dialog
 */
private void showAbout() {
    final AlertDialog dialog = showAlert(MainActivity.this,
            getString(R.string.app_name),
            R.layout.about,
            R.drawable.ic_ulogger_logo_24dp);
    final TextView versionLabel = (TextView) dialog.findViewById(R.id.about_version);
    versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME));
    final TextView descriptionLabel = (TextView) dialog.findViewById(R.id.about_description);
    final TextView description2Label = (TextView) dialog.findViewById(R.id.about_description2);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        descriptionLabel.setText(fromHtmlDepreciated(getString(R.string.about_description)));
        description2Label.setText(fromHtmlDepreciated(getString(R.string.about_description2)));
    } else {
        descriptionLabel.setText(Html.fromHtml(getString(R.string.about_description), android.text.Html.FROM_HTML_MODE_LEGACY));
        description2Label.setText(Html.fromHtml(getString(R.string.about_description2), android.text.Html.FROM_HTML_MODE_LEGACY));
    }
    final Button okButton = (Button) dialog.findViewById(R.id.about_button_ok);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}
 
Example 5
Project: Android-Gank-Share   File: EmptyView.java   View source code 6 votes vote down vote up
public EmptyView build(){
    if(parent == null)
        throw new IllegalArgumentException("No parent viewGroup");

    emptyView.view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.empty_view, parent, false);
    TextView textView = ButterKnife.findById(emptyView.view, R.id.text_empty_hint);
    textView.setText(emptyHint);
    Button button = ButterKnife.findById(emptyView.view, R.id.btn_empty_view);
    button.setText(buttonText);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mOnClickListener != null)
                mOnClickListener.onClick(v);
        }
    });
    parent.addView(emptyView.view);
    return emptyView;
}
 
Example 6
Project: Java-9-Programming-Blueprints   File: InstagramPreferencesFragment.java   View source code 6 votes vote down vote up
private void updateUI() {
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            final Button button = (Button) getView().findViewById(R.id.connectButton);
            if (!InstagramClient.instance().isAuthenticated()) {
                button.setText(getString(R.string.login));
                button.setOnClickListener(new LoginClickListener());
            } else {
                button.setText(getString(R.string.logout));
                button.setOnClickListener(new LogoutClickListener(button));
            }

        }
    });
}
 
Example 7
Project: Material-Calendar-View   File: RangePickerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.range_picker_activity);

    CalendarView calendarView = (CalendarView) findViewById(R.id.calendarView);

    Button getDateButton = (Button) findViewById(R.id.getDateButton);
    getDateButton.setOnClickListener(v -> {
        for (Calendar calendar : calendarView.getSelectedDates()) {
            System.out.println(calendar.getTime().toString());

            Toast.makeText(getApplicationContext(),
                    calendar.getTime().toString(),
                    Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 8
Project: treetracker-android   File: ExitFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
	
    View v = inflater.inflate(R.layout.fragment_exit, container, false);
    
    mSharedPreferences = getActivity().getSharedPreferences(
      	      "org.greenstand.android", Context.MODE_PRIVATE);

    Button yesBtn = (Button) v.findViewById(R.id.fragment_exit_yes);
    yesBtn.setOnClickListener(ExitFragment.this);

    Button noBtn = (Button) v.findViewById(R.id.fragment_exit_no);
    noBtn.setOnClickListener(ExitFragment.this);
    
    return v;
}
 
Example 9
Project: Nird2   File: ChangePasswordActivityTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() {
	MockitoAnnotations.initMocks(this);
	changePasswordActivity =
			Robolectric.setupActivity(TestChangePasswordActivity.class);
	passwordConfirmationWrapper = (TextInputLayout) changePasswordActivity
			.findViewById(R.id.new_password_confirm_wrapper);
	currentPassword = (EditText) changePasswordActivity
			.findViewById(R.id.current_password_entry);
	newPassword = (EditText) changePasswordActivity
			.findViewById(R.id.new_password_entry);
	newPasswordConfirmation = (EditText) changePasswordActivity
			.findViewById(R.id.new_password_confirm);
	strengthMeter = (StrengthMeter) changePasswordActivity
			.findViewById(R.id.strength_meter);
	changePasswordButton = (Button) changePasswordActivity
			.findViewById(R.id.change_password);
}
 
Example 10
Project: boohee_v5.6   File: BaseTimelineAdapter.java   View source code 6 votes vote down vote up
protected void initDeleteButton(Button button, final Post post) {
    if (post.own) {
        button.setVisibility(0);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (AccountUtils.isVisitorAccount(BaseTimelineAdapter.this.activity)) {
                    CheckAccountPopwindow.showVisitorPopWindow(BaseTimelineAdapter.this
                            .activity);
                } else {
                    BaseTimelineAdapter.this.showDeleteDialog(post);
                }
            }
        });
        return;
    }
    button.setVisibility(8);
}
 
Example 11
Project: ThunderMusic   File: OnlineSearchClearHistory.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    setContentView(R.layout.confirm_delete);
    getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT);
    activity = this;
    mPrompt = (TextView) findViewById(R.id.prompt);
    mButton = (Button) findViewById(R.id.delete);
    mButton.setOnClickListener(mButtonClicked);

    (findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });

    mPrompt.setText(getString(R.string.clear_online_dialog));
}
 
Example 12
Project: LucaHome-AndroidApplication   File: DownloadYoutubeVideoTask.java   View source code 6 votes vote down vote up
private void displayYoutubeIdDialog(@NonNull ArrayList<YoutubeVideoData> youtubeVideoDataList) {
    final Dialog dialog = new Dialog(_context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_listview);

    TextView title = dialog.findViewById(R.id.dialog_title_text_view);
    title.setText(_context.getResources().getString(R.string.select_youtube_video));

    final YoutubeVideoListAdapter listAdapter = new YoutubeVideoListAdapter(_context, youtubeVideoDataList, dialog::dismiss);
    ListView listView = dialog.findViewById(R.id.dialog_list_view);
    listView.setAdapter(listAdapter);
    listView.setVisibility(View.VISIBLE);

    Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(view -> dialog.dismiss());

    dialog.setCancelable(true);
    dialog.show();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    } else {
        Logger.getInstance().Warning(TAG, "Window is null!");
    }
}
 
Example 13
Project: CIA   File: FollowersRequestAdapter.java   View source code 6 votes vote down vote up
public ViewHolder(final View itemView) {
    super(itemView);

    followRequestee = (TextView) itemView.findViewById(R.id.followRequesteeName);
    approveButton = (Button) itemView.findViewById(R.id.approveButton);
    declineButton = (Button) itemView.findViewById(R.id.declineButton);

    // listens when an item is clicked
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (listener != null) {
                int position = getAdapterPosition();
                if (position != RecyclerView.NO_POSITION) {
                    listener.onItemClick(itemView, position);
                }
            }
        }
    });
}
 
Example 14
Project: firebase-testlab-instr-lib   File: TitleEditor.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.title_editor);

    // Get the uri of the note whose title we want to edit
    mUri = getIntent().getData();

    // Get a cursor to access the note
    mCursor = managedQuery(mUri, PROJECTION, null, null, null);

    // Set up click handlers for the text field and button
    mText = (EditText) this.findViewById(R.id.title);
    mText.setOnClickListener(this);
    
    Button b = (Button) findViewById(R.id.ok);
    b.setOnClickListener(this);
}
 
Example 15
Project: GitHub   File: MockLocationsActivity.java   View source code 6 votes vote down vote up
private void initViews() {
    latitudeInput = (EditText) findViewById(R.id.latitude_input);
    longitudeInput = (EditText) findViewById(R.id.longitude_input);
    mockLocationView = (TextView) findViewById(R.id.mock_location_view);
    updatedLocationView = (TextView) findViewById(R.id.updated_location_view);
    mockModeToggleButton = (ToggleButton) findViewById(R.id.toggle_button);
    setLocationButton = (Button) findViewById(R.id.set_location_button);

    mockModeToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setMockMode(isChecked);
            setLocationButton.setEnabled(isChecked);
        }
    });
    setLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addMockLocation();
        }
    });
}
 
Example 16
Project: IPCCommunication   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTextView = (TextView) findViewById(R.id.tv_service);
    tv_state = (TextView) findViewById(R.id.tv_state);
    btnGet = (Button) findViewById(R.id.btn_getService);
    btn_bind = (Button) findViewById(R.id.btn_bind);
    btn_unbind = (Button) findViewById(R.id.btn_unbind);
    btnGet.setEnabled(false);
    tv_state.setText("  服务未绑定 ");
    mClientUtils = new ClientUtils(this);
    mClientUtils.setConnectListener(mConnectListener);
    btn_bind.setEnabled(true);
    btn_unbind.setEnabled(false);
}
 
Example 17
Project: 2017.2-codigo   File: AdicionarEstadoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.alterar_estado);
    db = SQLEstadosHelper.getInstance(this);

    UF = (EditText) findViewById(R.id.txtUF);
    nomeEstado = (EditText) findViewById(R.id.txtNome);

    Button b = (Button) findViewById(R.id.btnInserirEstado);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new InsereTask().execute(UF.getText().toString(), nomeEstado.getText().toString());
        }
    });
}
 
Example 18
Project: CSkin   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    button = (Button) findViewById(R.id.button);
    probar = (ProgressBar) findViewById(R.id.probar);

    button.setOnClickListener(v -> {
        probar.setVisibility(View.VISIBLE);
        update();
        probar.setVisibility(View.GONE);
    });


}
 
Example 19
Project: InstaLikeView   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mInstaLikeView = (InstaLikeView) findViewById(R.id.insta_like_view);
    mButton = (Button) findViewById(R.id.button);

    mInstaLikeView.setLikeColor(ContextCompat.getColor(this, R.color.colorAccent));

    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mInstaLikeView.start();
        }
    });
}
 
Example 20
Project: SystemUITuner2   File: SetupActivity.java   View source code 6 votes vote down vote up
@Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            View view = super.onCreateView(inflater, container, savedInstanceState);
//            TextView adb_instructions = (TextView) (view != null ? view.findViewById(R.id.adb_instructions) : null);
//            if (adb_instructions != null) adb_instructions.setMovementMethod(LinkMovementMethod.getInstance());

            Button instructions = (Button) (view != null ? view.findViewById(R.id.adb_instructions_button) : null);
            if (instructions != null) instructions.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Uri uri = Uri.parse("https://developer.android.com/studio/command-line/adb.html");
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);
                }
            });

            return view;
        }
 
Example 21
Project: pius1   File: MaterialDialog.java   View source code 6 votes vote down vote up
/**
        * set negative button
        *
        * @param text the name of button
        */
       public void setNegativeButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setText(text);
           button.setTextColor(Color.argb(222, 0, 0, 0));
           button.setTextSize(14);
           button.setGravity(Gravity.CENTER);
           button.setPadding(0, 0, 0, dip2px(8));
           button.setOnClickListener(listener);
           if (mButtonLayout.getChildCount() > 0)
    {
               params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
               button.setLayoutParams(params);
               mButtonLayout.addView(button, 1);
           }
    else
    {
               button.setLayoutParams(params);
               mButtonLayout.addView(button);
           }
       }
 
Example 22
Project: chromium-for-android-56-debug-video   File: SadTabViewFactory.java   View source code 6 votes vote down vote up
/**
 * @param context Context of the resulting Sad Tab view.
 * @param suggestionAction Action to be executed when user clicks "try these suggestions".
 * @param reloadButtonAction Action to be executed when Reload button is pressed.
 *                           (e.g., refreshing the page)
 * @return A "Sad Tab" view instance which is used in place of a crashed renderer.
 */
public static View createSadTabView(
        Context context, final OnClickListener suggestionAction,
        OnClickListener reloadButtonAction) {
    // Inflate Sad tab and initialize.
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    View sadTabView = inflater.inflate(R.layout.sad_tab, null);

    TextView messageText = (TextView) sadTabView.findViewById(R.id.sad_tab_message);
    messageText.setText(getHelpMessage(context, suggestionAction));
    messageText.setMovementMethod(LinkMovementMethod.getInstance());

    Button reloadButton = (Button) sadTabView.findViewById(R.id.sad_tab_reload_button);
    reloadButton.setOnClickListener(reloadButtonAction);

    return sadTabView;
}
 
Example 23
Project: spinify_android   File: DialogUtils.java   View source code 6 votes vote down vote up
private static void setTypeface(TypefaceHelper helper, AlertDialog alertDialog, String typefaceName, int style) {
	Button positive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
	Button negative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
	Button neutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
	TextView message = (TextView) alertDialog.findViewById(android.R.id.message);
	if (positive != null) {
		helper.setTypeface(positive, typefaceName, style);
	}
	if (negative != null) {
		helper.setTypeface(negative, typefaceName, style);
	}
	if (neutral != null) {
		helper.setTypeface(neutral, typefaceName, style);
	}
	if (message != null) {
		helper.setTypeface(message, typefaceName, style);
	}
}
 
Example 24
Project: browser   File: ECAlertDialog.java   View source code 6 votes vote down vote up
/**
 *
 */
private void initView() {
    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(layoutParams);
    mButtons = new ArrayList<Button>();
    Button leftBtn = (Button) findViewById(R.id.dilaog_button1);
    leftBtn.setOnClickListener(this);
    mButtons.add(leftBtn);
    Button middleBtn = (Button) findViewById(R.id.dilaog_button2);
    middleBtn.setOnClickListener(this);
    mButtons.add(middleBtn);
    Button rightBtn = (Button) findViewById(R.id.dilaog_button3);
    rightBtn.setOnClickListener(this);
    mButtons.add(rightBtn);
    mLayoutTitle = findViewById(R.id.dialog_layout_title);
    mLayoutContent = ((ViewGroup) findViewById(R.id.dialog_layout_content));
    mLayoutButton = findViewById(R.id.dialog_layout_button);
    setCancelable(true);
    setCanceledOnTouchOutside(true);
    setTitle(R.string.dialog_title_alert);
}
 
Example 25
Project: GSB-2017-Android   File: ClientsAdapter.java   View source code 6 votes vote down vote up
ClientVieHolder(View itemView) {
    super(itemView);
    textView_clientName = (TextView) itemView.findViewById(R.id.textView_nomClient);
    textView_clientName_title = (TextView) itemView.findViewById(R.id.textView_nomClient_titre);
    textView_clientTelephone = (TextView) itemView.findViewById(R.id.textView_telClient);
    textView_clientTelephone_title = (TextView) itemView.findViewById(R.id.textView_telClient_titre);
    textView_clientAddresse = (TextView) itemView.findViewById(R.id.textView_adrClient);
    textView_clientAddresse_title = (TextView) itemView.findViewById(R.id.textView_adrClient_titre);
    textView_clientTitle = (TextView) itemView.findViewById(R.id.textView_titreClient);
    textView_clientTitle_title = (TextView) itemView.findViewById(R.id.textView_titreClient_titre);
    textView_clientMobile = (TextView) itemView.findViewById(R.id.textView_mobileClient);
    textView_clientMobile_title = (TextView) itemView.findViewById(R.id.textView_mobileClient_titre);
    textView_clientEmail = (TextView) itemView.findViewById(R.id.textView_emailClient);
    textView_clientEmail_title = (TextView) itemView.findViewById(R.id.textView_email_titre);
    buttonUndo = (Button) itemView.findViewById(R.id.undo_button);
    cardView_client = (CardView) itemView.findViewById(R.id.cardView_client);
    linearLayout_iconBackground = (LinearLayout) itemView.findViewById(R.id.linearLayout_iconBackground);
}
 
Example 26
Project: LocationTracking   File: CustomDialog.java   View source code 6 votes vote down vote up
public static void buildSingleButtonDialog(Activity activity, String title, String message) {
    final Dialog dialog = buildDialog(activity, title, message);

    Button cancelButton = ButterKnife.findById(dialog, R.id.btn_cancel);
    cancelButton.setVisibility(View.INVISIBLE);

    Button okButton = ButterKnife.findById(dialog, R.id.btn_yes);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    dialog.show();
}
 
Example 27
Project: HeadlineNews   File: MineMineFragment.java   View source code 6 votes vote down vote up
@Override
protected void initViews() {

    /** 1、头像区域 */

    /** 2、动态粉丝区域*/

    /** 3、收藏、历史、夜间 区域*/
    Button collectBtn = (Button) findViewById(R.id.id_my_collect_btn);
    Button historyBtn = (Button) findViewById(R.id.id_my_history_btn);
    Button nightModeBtn = (Button) findViewById(R.id.id_night_mode_btn);

    CompoundDrawableUtil.changeCompoundDrawableSize(collectBtn, 1, 20);
    CompoundDrawableUtil.changeCompoundDrawableSize(historyBtn, 1, 20);
    CompoundDrawableUtil.changeCompoundDrawableSize(nightModeBtn, 1, 20);

    collectBtn.setOnClickListener(this);
    historyBtn.setOnClickListener(this);
    nightModeBtn.setOnClickListener(this);

    /** 4、cells */

}
 
Example 28
Project: NetworkStateView   File: MainActivity.java   View source code 6 votes vote down vote up
private void initView() {

        networkStateView = (NetworkStateView) findViewById(R.id.nsv_state_view);

        Button bt_loading = (Button) findViewById(R.id.bt_loading);
        Button bt_error = (Button) findViewById(R.id.bt_error);
        Button bt_noNetwork = (Button) findViewById(R.id.bt_no_network);
        Button bt_empty = (Button) findViewById(R.id.bt_empty);

        bt_loading.setOnClickListener(this);
        bt_error.setOnClickListener(this);
        bt_noNetwork.setOnClickListener(this);
        bt_empty.setOnClickListener(this);

        networkStateView.setOnRefreshListener(this);
        networkStateView.showLoading();
        showSuccess();
    }
 
Example 29
Project: BBSSDK-for-Android   File: TestActivity.java   View source code 6 votes vote down vote up
@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MobSDK.init(this);
		setContentView(ResHelper.getLayoutRes(this, "layout_test"));
		cleverImageView = (CleverImageView) findViewById(ResHelper.getIdRes(this, "cleverImageView"));
		btnTest = (Button) findViewById(ResHelper.getIdRes(this, "btnTest"));
		btnTest.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
//                cleverImageView.setOval(false);
				cleverImageView.setBorderColor(Color.BLUE);
				cleverImageView.setBorderWidthDP(2);
				cleverImageView.setCornerRadiiDP(10, 5, 20, 30);
				cleverImageView.setImageUrl(IMAGE_URL);
			}
		});
	}
 
Example 30
Project: oma-riista-android   File: HomeViewFragment.java   View source code 6 votes vote down vote up
private void updateObservationQuickButtons(final View view) {
    ObservationDatabase.getInstance().loadLatestObservationSpecimens(2, new ObservationsListener() {
        @Override
        public void onObservations(List<GameObservation> observations) {
            if (isAdded()) {
                List<Integer> latest = new ArrayList<>();
                for (GameObservation observation : observations) {
                    latest.add(observation.gameSpeciesCode);
                }

                setupQuickButtons(view.findViewById(R.id.layout_quick_observation), latest, R.string.logobservation_template, new OnQuickButtonInitListener() {
                    @Override
                    public void onInit(Button button, final Species species) {
                        button.setOnClickListener(new OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                startObservationEditActivity(species);
                            }
                        });
                    }
                });
            }
        }
    });
}
 
Example 31
Project: Nird2   File: InvitationViewHolder.java   View source code 5 votes vote down vote up
public InvitationViewHolder(View v) {
	super(v);

	avatar = (TextAvatarView) v.findViewById(R.id.avatarView);
	name = (TextView) v.findViewById(R.id.forumNameView);
	sharedBy = (TextView) v.findViewById(R.id.sharedByView);
	subscribed = (TextView) v.findViewById(R.id.forumSubscribedView);
	accept = (Button) v.findViewById(R.id.acceptButton);
	decline = (Button) v.findViewById(R.id.declineButton);
}
 
Example 32
Project: boohee_v5.6   File: AlertController.java   View source code 5 votes vote down vote up
private void setupButtons(ViewGroup buttonPanel) {
    boolean hasButtons = false;
    int whichButtons = 0;
    this.mButtonPositive = (Button) buttonPanel.findViewById(16908313);
    this.mButtonPositive.setOnClickListener(this.mButtonHandler);
    if (TextUtils.isEmpty(this.mButtonPositiveText)) {
        this.mButtonPositive.setVisibility(8);
    } else {
        this.mButtonPositive.setText(this.mButtonPositiveText);
        this.mButtonPositive.setVisibility(0);
        whichButtons = 0 | 1;
    }
    this.mButtonNegative = (Button) buttonPanel.findViewById(16908314);
    this.mButtonNegative.setOnClickListener(this.mButtonHandler);
    if (TextUtils.isEmpty(this.mButtonNegativeText)) {
        this.mButtonNegative.setVisibility(8);
    } else {
        this.mButtonNegative.setText(this.mButtonNegativeText);
        this.mButtonNegative.setVisibility(0);
        whichButtons |= 2;
    }
    this.mButtonNeutral = (Button) buttonPanel.findViewById(16908315);
    this.mButtonNeutral.setOnClickListener(this.mButtonHandler);
    if (TextUtils.isEmpty(this.mButtonNeutralText)) {
        this.mButtonNeutral.setVisibility(8);
    } else {
        this.mButtonNeutral.setText(this.mButtonNeutralText);
        this.mButtonNeutral.setVisibility(0);
        whichButtons |= 4;
    }
    if (whichButtons != 0) {
        hasButtons = true;
    }
    if (!hasButtons) {
        buttonPanel.setVisibility(8);
    }
}
 
Example 33
Project: Android_watch_magpie   File: AddValueFragment.java   View source code 5 votes vote down vote up
private void setAcceptAction(Button acceptButton, final EditText dateEditText,
                             final EditText timeEditText, final TextInputLayout... textInputLayouts) {
    acceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Validate the values
            if (!areValuesValid(dateEditText, timeEditText, textInputLayouts)) {
                return;
            }

            switch (type) {
                case GLUCOSE:
                case WEIGHT:
                    SingleValue newSingleValue = newSingleValueInstance(textInputLayouts[0], dateEditText, timeEditText);
                    // Store the new glucose measurement in the database
                    valueDAO.createValue(newSingleValue);
                    // Send it to the ListValuesFragment
                    callback.addSingleValue(newSingleValue);
                    break;
                case BLOOD_PRESSURE:
                    DoubleValue newDoubleValue = newDoubleValueInstance(dateEditText, timeEditText, textInputLayouts);
                    valueDAO.createValue(newDoubleValue);
                    callback.addDoubleValue(newDoubleValue);
                    break;
            }

            // Remove the values from the UI elements
            for (TextInputLayout textInputLayout : textInputLayouts) {
                textInputLayout.getEditText().setText("");
                textInputLayout.clearFocus();
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(textInputLayout.getWindowToken(), 0);
            }
            dateEditText.setText("");
            timeEditText.setText("");
        }
    });
}
 
Example 34
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ChangePasswordDialog.java   View source code 5 votes vote down vote up
private void initViews(View v) {

        mEtOldPassword = (EditText) v.findViewById(R.id.et_old_password);
        mEtNewPassword = (EditText) v.findViewById(R.id.et_new_password);
        mTiOldPassword = (TextInputLayout) v.findViewById(R.id.ti_old_password);
        mTiNewPassword = (TextInputLayout) v.findViewById(R.id.ti_new_password);
        mTvMessage = (TextView) v.findViewById(R.id.tv_message);
        mBtChangePassword = (Button) v.findViewById(R.id.btn_change_password);
        mBtCancel = (Button) v.findViewById(R.id.btn_cancel);
        mProgressBar = (ProgressBar) v.findViewById(R.id.progress);

        mBtChangePassword.setOnClickListener(view -> changePassword());
        mBtCancel.setOnClickListener(view -> dismiss());
    }
 
Example 35
Project: XFrame   File: XLogDemoActivity.java   View source code 5 votes vote down vote up
@Override
public void initView() {
    button = (Button) findViewById(R.id.button);
    button2 = (Button) findViewById(R.id.button2);
    button3 = (Button) findViewById(R.id.button3);
    button5 = (Button) findViewById(R.id.button5);
    button4 = (Button) findViewById(R.id.button4);
    textView = (TextView) findViewById(R.id.textView);
    button.setOnClickListener(this);
    button2.setOnClickListener(this);
    button3.setOnClickListener(this);
    button4.setOnClickListener(this);
    button5.setOnClickListener(this);
}
 
Example 36
Project: RxJava2-Android-Sample   File: BehaviorSubjectExampleActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_example);
    btn = (Button) findViewById(R.id.btn);
    textView = (TextView) findViewById(R.id.textView);

    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doSomeWork();
        }
    });
}
 
Example 37
Project: pracler   File: FindUserActivity.java   View source code 5 votes vote down vote up
private void viewInitialize()
{
    editText = (EditText) findViewById(R.id.findText);
    listView = (ListView) findViewById(R.id.listview);
    button = (Button) findViewById(R.id.commit);
    loadingbar = (AVLoadingIndicatorView) findViewById(R.id.loadingBar);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    getSupportActionBar().setTitle(getString(R.string.search_user));

}
 
Example 38
Project: Demos   File: FillBlankView.java   View source code 5 votes vote down vote up
@Override
public void onClick(final View widget) {
    View view = LayoutInflater.from(context).inflate(R.layout.layout_input, null);
    final EditText etInput = (EditText) view.findViewById(R.id.et_answer);
    Button btnFillBlank = (Button) view.findViewById(R.id.btn_fill_blank);

    // 显示原有答案
    String oldAnswer = answerList.get(position);
    if (!TextUtils.isEmpty(oldAnswer)) {
        etInput.setText(oldAnswer);
        etInput.setSelection(oldAnswer.length());
    }

    final PopupWindow popupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT, dp2px(40));
    // 获取焦点
    popupWindow.setFocusable(true);
    // 为了防止弹出菜单获取焦点之后,点击Activity的其他组件没有响应
    popupWindow.setBackgroundDrawable(new PaintDrawable());
    // 设置PopupWindow在软键盘的上方
    popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    // 弹出PopupWindow
    popupWindow.showAtLocation(tvContent, Gravity.BOTTOM, 0, 0);

    btnFillBlank.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // 填写答案
            String answer = etInput.getText().toString();
            fillAnswer(answer, position);
            popupWindow.dismiss();
        }
    });

    // 显示软键盘
    InputMethodManager inputMethodManager =
            (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
 
Example 39
Project: polling-station-app   File: ManualInputActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manual_input);
    Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(appBar);
    Util.setupAppBar(appBar, this);
    Typeface typeFace= Typeface.createFromAsset(getAssets(), "fonts/ro.ttf");

    docNumber = (EditText) findViewById(R.id.doc_num);
    docNumber.setTypeface(typeFace);
    TextView docNumTitle = (TextView) findViewById(R.id.doc_num_title);
    TextView dobTitle = (TextView) findViewById(R.id.dob_title);
    TextView expDateTitle = (TextView) findViewById(R.id.exp_date_title);
    docNumTitle.setTypeface(typeFace);
    dobTitle.setTypeface(typeFace);
    expDateTitle.setTypeface(typeFace);

    Button submitBut = (Button) findViewById(R.id.submit_button);
    submitBut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(verifyInput()) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra(DocumentData.identifier, getData());
                setResult(Activity.RESULT_OK, returnIntent);
                finish();
            }
        }
    });
    setupDOBSpinners();
    setupExpirySpinners();

    // When docData was previously filled in, update text fields
    if(getIntent().hasExtra(DocumentData.identifier)) {
        putData(getIntent().getExtras());
    }
}
 
Example 40
Project: thesis-project   File: AttendanceAddActivity.java   View source code 5 votes vote down vote up
private void init() {
    linearLayoutAttendance = (LinearLayout) findViewById(add_add3);
    recyclerView = (RecyclerView) findViewById(R.id.add_recycler3);
    btnBackButton = (Button) findViewById(R.id.add_back3);

    linearLayoutAttendance.setOnClickListener(this);
    btnBackButton.setOnClickListener(this);

    progressBar = (ProgressBar) findViewById(R.id.progres_man_att);
    progressBar.setVisibility(View.VISIBLE);
}