本文整理匯總了Java中android.widget.EditText.getLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.getLayoutParams方法的具體用法?Java EditText.getLayoutParams怎麽用?Java EditText.getLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.getLayoutParams方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInitialized
import android.widget.EditText; //導入方法依賴的package包/類
@Override
public void onInitialized(MainPresenter presenter, MainViewState viewState) {
if (!presenter.isInitialized()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.enter_key);
builder.setMessage(R.string.key_requirments_message);
EditText editText = new EditText(this);
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(16)});
builder.setView(editText);
builder.setPositiveButton(R.string.apply, null);
AlertDialog dialog = builder.create();
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.show();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
if (editText.getText().length() == 16) {
String key = editText.getText().toString();
presenter.initializeWithKey(key);
presenter.getValues();
dialog.dismiss();
} else {
Toast.makeText(this, R.string.bad_key, Toast.LENGTH_LONG).show();
}
});
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) editText.getLayoutParams();
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, getResources().getDisplayMetrics());
layoutParams.setMargins(margin, margin, margin, margin);
editText.requestLayout();
} else {
if (!viewState.isPrefsLoaded() && !presenter.isTaskRunning(MainPresenter.TASK_GET_RUNNING)) {
presenter.getValues();
}
}
}