本文整理匯總了Java中android.support.v7.widget.AppCompatEditText.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatEditText.setText方法的具體用法?Java AppCompatEditText.setText怎麽用?Java AppCompatEditText.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.AppCompatEditText
的用法示例。
在下文中一共展示了AppCompatEditText.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showEditDialog
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void showEditDialog(TodoItem item) {
View customView = LayoutInflater.from(this).inflate(R.layout.dialog_todo_edit, null);
final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText);
editText.setText(item.getDescription());
editText.setSelection(item.getDescription().length());
materialDialog = new MaterialDialog.Builder(this)
.customView(customView, false)
.positiveColorRes(R.color.positive_color)
.negativeColorRes(R.color.positive_color)
.positiveText(R.string.action_sure)
.negativeText(R.string.action_cancel)
.onPositive((dialog, which) -> {
String text = editText.getText().toString();
if (!TextUtils.isEmpty(text)) {
actionCreator.createItemEditAction(item.getId(), text, item.isCompleted(), item.isStared());
dialog.dismiss();
}
})
.build();
materialDialog.show();
}
示例2: buildEditDialog
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private AlertDialog buildEditDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
AppCompatEditText name = new AppCompatEditText(getActivity());
name.setText(mEvent.getName());
int padding = Util.getPixelsFromDp(getActivity(), 16);
name.setPadding(padding, padding, padding, padding);
builder.setView(name);
builder.setTitle("Edit Event");
builder.setPositiveButton("Ok", (dialog, which) -> {
mEvent.setName(name.getText().toString());
mEvent.update();
((BaseActivity) getActivity()).setActionBarSubtitle(mEvent.getName());
});
builder.setNegativeButton("Cancel", null);
return builder.create();
}
示例3: doRenameWindow
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void doRenameWindow() {
final AppCompatEditText editText = new AppCompatEditText(this);
editText.setText(getCurrentTermSession().getTitle());
final AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle(R.string.input_window_title);
b.setView(editText);
b.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
doChangeWindowTitle(editText.getText().toString());
}
});
b.setNegativeButton(android.R.string.no, null);
b.show();
}
示例4: initView
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void initView()
{
toolbar = (android.support.v7.widget.Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ediContent = (AppCompatEditText) findViewById(R.id.id_lxw_push_content);
scrollPicContent = (HorizontalScrollView) findViewById(R.id.id_lxw_push_scrollPicContent);
layPicContent = (LinearLayout) findViewById(R.id.id_lxw_push_layPicContent);
btnCamera = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnCamera);
btnEmotion = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnEmotion);
btnSend = (LinearLayout) findViewById(R.id.btnSend);
emojPager = (ViewPager) findViewById(R.id.id_lxw_push_emoj_viewpager);
SharedPreferences sharedPreferencesb = getSharedPreferences("fba", AppCompatActivity.MODE_PRIVATE);
String r = sharedPreferencesb.getString("stytoolpro", "");
ediContent.setText(r);
}
示例5: onCreate
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
editText = (AppCompatEditText) findViewById(R.id.edittext);
editText.setTextColor(getResources().getColor(Utils.LIGHTTHEME ? R.color.black : R.color.white));
if ((originalText = getIntent().getExtras().getString(TEXT_ARG)) != null)
editText.setText(originalText);
ActionBar actionBar;
if ((name = getIntent().getExtras().getString(NAME_ARG)) != null && (actionBar = getSupportActionBar()) != null)
actionBar.setTitle(name);
}
示例6: onCreate
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
editText = (AppCompatEditText) findViewById(R.id.edittext);
editText.setTextColor(ContextCompat.getColor(this, Utils.DARKTHEME ? R.color.white : R.color.black));
if ((originalText = getIntent().getExtras().getString(TEXT_ARG)) != null)
editText.setText(originalText);
ActionBar actionBar;
if ((name = getIntent().getExtras().getString(NAME_ARG)) != null && (actionBar = getSupportActionBar()) != null)
actionBar.setTitle(name);
}
示例7: onCreate
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
editText = (AppCompatEditText) findViewById(R.id.edittext);
editText.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black));
if ((originalText = getIntent().getExtras().getString(TEXT_ARG)) != null)
editText.setText(originalText);
ActionBar actionBar;
if ((name = getIntent().getExtras().getString(NAME_ARG)) != null && (actionBar = getSupportActionBar()) != null)
actionBar.setTitle(name);
}
示例8: onCreateView
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView=null;
final String content = getArguments().getString(ARG_CONTENT);
switch (getArguments().getInt(ARG_SECTION_NUMBER)) {
case TYPE_EDIT:
showHelp(container);
rootView = inflater.inflate(R.layout.fragment_markdown, container, false);
edit =(AppCompatEditText) rootView.findViewById(R.id.markdown_edit);
edit.requestFocus();
if(content !=null){
edit.setText(content);
historyList.add(new History(0,content));
}
edit.addTextChangedListener(textWatcher);
break;
case TYPE_VIEW:
showHelp(container);
rootView=inflater.inflate(R.layout.fragment_webview,container,false);
webView=(MarkDownWebView) rootView.findViewById(R.id.web_view);
webView.ini();
webView.setBackgroundColor(AppPreferenceUtil.getEditBgColor());
webView.loadUrl("file:///android_asset/markdown.html");
webView.postDelayed(new Runnable() {
@Override
public void run() {
parseMarkdown(content);
getView().findViewById(R.id.loading_bg).setVisibility(View.GONE);
getView().findViewById(R.id.actual_view).setVisibility(View.VISIBLE);
}
},300);
}
return rootView;
}
示例9: onCreateDialogLayout
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void onCreateDialogLayout(@Nullable String restoredName) {
mInputLayout = new TextInputLayout(getContext());
mEditText = new AppCompatEditText(getContext());
mEditText.setInputType(InputType.TYPE_CLASS_TEXT);
mEditText.setHint(R.string.hint_playlist_name);
mEditText.setText(restoredName);
mInputLayout.addView(mEditText);
mInputLayout.setErrorEnabled(true);
mEditText.addTextChangedListener(this);
}
示例10: initLoginDialogViews
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void initLoginDialogViews(View loginDialogView) {
usernameEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_username);
passwordEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_password);
usernameTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_username);
passwordTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_password);
mAnonymousCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_anonymous);
mSecureCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_secure);
mAnonymousCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
usernameEditText.setEnabled(false);
passwordEditText.setEnabled(false);
} else {
usernameEditText.setEnabled(true);
passwordEditText.setEnabled(true);
}
});
// init dialog views as per preferences
if (getUsernameFromPreferences().equals(FTPService.DEFAULT_USERNAME)) {
mAnonymousCheckBox.setChecked(true);
} else {
usernameEditText.setText(getUsernameFromPreferences());
passwordEditText.setText(getPasswordFromPreferences());
}
if (getSecurePreference()) {
mSecureCheckBox.setChecked(true);
} else mSecureCheckBox.setChecked(false);
// check if we have a keystore
InputStream stream = getResources().openRawResource(R.raw.key);
if (stream == null) {
mSecureCheckBox.setEnabled(false);
mSecureCheckBox.setChecked(false);
setSecurePreference(false);
}
}
示例11: onCreateDialog
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = getActivity().getLayoutInflater();
final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
name = (AppCompatEditText) view.findViewById(R.id.name);
host = (AppCompatEditText) view.findViewById(R.id.host);
port = (AppCompatEditText) view.findViewById(R.id.port);
path = (AppCompatEditText) view.findViewById(R.id.path);
hostContainer = view.findViewById(R.id.hostContainer);
pathContainer = view.findViewById(R.id.pathContainer);
username = (AppCompatEditText) view.findViewById(R.id.username);
usernameContainer = view.findViewById(R.id.usernameContainer);
password = (AppCompatEditText) view.findViewById(R.id.password);
passwordContainer = view.findViewById(R.id.passwordContainer);
scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
}
});
if(connection_id != 0){
NetworkConnection connection =
NetworkConnection.fromConnectionId(getActivity(), connection_id);
ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
scheme.setSelection(spinnerPosition);
name.setText(connection.getName());
host.setText(connection.getHost());
port.setText(Integer.toString(connection.getPort()));
path.setText(connection.getPath());
username.setText(connection.getUserName());
password.setText(connection.getPassword());
anonymous.setChecked(connection.isAnonymousLogin());
if(SERVER.equals(connection.getType())){
hostContainer.setVisibility(View.GONE);
pathContainer.setVisibility(View.VISIBLE);
}
}
builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection");
builder.setView(view);
builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final BaseActivity activity = (BaseActivity) getActivity();
NetworkConnection networkConnection = getNetworkConnection();
if(validate(networkConnection)){
new CreateConnectionTask(activity, networkConnection).executeOnExecutor(
ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();
}
示例12: updateView
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void updateView(Status item){
TextView tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
long replyTweetId = item.getInReplyToStatusId();
if (replyTweetId != -1){
tweetIsReply.setVisibility(VISIBLE);
tweetIsReply.setOnClickListener(v -> startActivity(getIntent(this, replyTweetId)));
} else {
tweetIsReply.setVisibility(GONE);
}
StatusView statusView = new StatusView(this);
statusView.setStatus(item);
ViewGroup cview = (ViewGroup) statusView.getChildAt(0);
ViewGroup sview = (ViewGroup) cview.getChildAt(0);
cview.removeView(sview);
FrameLayout statusViewFrame = findViewById(R.id.tweet_show_tweet);
statusViewFrame.removeAllViews();
statusViewFrame.addView(sview);
((TextView)findViewById(R.id.tweet_show_timestamp)).setText(
DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL)
.format(item.getCreatedAt())
);
TextView viaText= findViewById(R.id.tweet_show_via);
viaText.setText(TwitterStringUtils.convertUrlSpanToCustomTabs(Html.fromHtml("via:"+item.getSource()), this));
viaText.setMovementMethod(new LinkMovementMethod());
AppCompatEditText replyText= findViewById(R.id.tweet_show_tweet_reply_text);
AppCompatButton replyButton= findViewById(R.id.tweet_show_tweet_reply_button);
UserMentionEntity[] users = item.getUserMentionEntities();
replyText.setText(TwitterStringUtils.convertToReplyTopString(
GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(),
item.getUser().getScreenName(),
users
));
replyButton.setOnClickListener(v -> {
replyButton.setEnabled(false);
PostTweetModel model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
model.setTweetText(replyText.getText().toString());
model.setInReplyToStatusId(item.getId());
subscriptions.add(
model.postTweet()
.subscribe(
it -> {
replyText.setText(TwitterStringUtils.convertToReplyTopString(
GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(),
item.getUser().getScreenName(), users
));
replyButton.setEnabled(true);
Toast.makeText(ShowTweetActivity.this,R.string.succeeded,Toast.LENGTH_SHORT).show();
},
e->{
e.printStackTrace();
Toast.makeText(ShowTweetActivity.this,R.string.error_occurred,Toast.LENGTH_SHORT).show();
replyButton.setEnabled(true);
}
)
);
});
}
示例13: onCreateDialog
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogView = inflater.inflate(R.layout.fragment_explore_dialog, null);
exploreSearch = (AppCompatEditText) dialogView.findViewById(R.id.explore_searchbar);
exploreToggleState = (RadioGroup) dialogView.findViewById(R.id.explore_radio_group);
if (searchContentOverride != null) {
exploreSearch.setText(searchContentOverride);
}
if (searchTypeOverride != NO_SEARCH_TYPE_OVERRIDE) {
switch (searchTypeOverride) {
case ExploreActivity.EXPLORE_NATION:
exploreToggleState.check(R.id.explore_radio_nation);
break;
case ExploreActivity.EXPLORE_REGION:
exploreToggleState.check(R.id.explore_radio_region);
break;
}
}
DialogInterface.OnClickListener dialogListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startExploreActivity();
}
};
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext(), RaraHelper.getThemeMaterialDialog(getContext()));
dialogBuilder.setTitle(R.string.menu_explore)
.setView(dialogView)
.setPositiveButton(R.string.explore_positive, dialogListener)
.setNegativeButton(R.string.explore_negative, null);
// Get focus on edit text and open keyboard
exploreSearch.requestFocus();
Dialog d = dialogBuilder.create();
d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return d;
}
示例14: onCreate
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_telegram_compose);
isInProgress = false;
// Either get data from intent or restore state
if (getIntent() != null) {
replyId = getIntent().getIntExtra(REPLY_ID_DATA, NO_REPLY_ID);
recipients = getIntent().getStringExtra(RECIPIENTS_DATA);
isDeveloperTg = getIntent().getBooleanExtra(DEVELOPER_TG_DATA, false);
}
String savedContent = null;
if (savedInstanceState != null) {
replyId = savedInstanceState.getInt(REPLY_ID_DATA, NO_REPLY_ID);
isDeveloperTg = savedInstanceState.getBoolean(DEVELOPER_TG_DATA, false);
recipients = savedInstanceState.getString(RECIPIENTS_DATA);
savedContent = savedInstanceState.getString(TG_CONTENT_DATA);
}
mView = findViewById(R.id.telegram_compose_main);
headerCardView = (CardView) findViewById(R.id.telegram_compose_header) ;
developerCardView = (CardView) findViewById(R.id.telegram_compose_developer_header);
headerCardView.setVisibility(isDeveloperTg ? View.GONE : View.VISIBLE);
developerCardView.setVisibility(isDeveloperTg ? View.VISIBLE : View.GONE);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.telegram_compose_refresher);
mSwipeRefreshLayout.setColorSchemeResources(RaraHelper.getThemeRefreshColours(this));
mSwipeRefreshLayout.setEnabled(false);
Toolbar toolbar = (Toolbar) findViewById(R.id.telegram_compose_toolbar);
setToolbar(toolbar);
recipientsField = (AppCompatEditText) findViewById(R.id.telegram_compose_recipients);
if (recipients != null && recipients.length() > 0) {
recipientsField.setText(recipients);
if (replyId != NO_REPLY_ID) {
// If this is a reply telegram, don't let user edit this field
recipientsField.setEnabled(false);
recipientsField.setFocusable(false);
}
}
senderField = (TextView) findViewById(R.id.telegram_compose_sender);
senderField.setText(PinkaHelper.getActiveUser(this).name);
content = (AppCompatEditText) findViewById(R.id.telegram_compose_content);
if (savedContent != null) {
content.setText(savedContent);
}
content.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
示例15: showValueDialog
import android.support.v7.widget.AppCompatEditText; //導入方法依賴的package包/類
private void showValueDialog() {
/*
Ideally, the View that this ViewHolder wraps would have the EditText directly
in it without doing the trickery below where it disguises a TextView as an EditText
and opens an AlertDialog, but there are severe penalties with nesting EditTexts in
a RecyclerView with a LinearLayoutManager. With no code in the ReyclerView
Adapter's .onBindViewHolder() method, GC will kick in frequently when scrolling
to free ~2MB from the heap while pausing for around 60ms (which may also be
complimented by extra layout calls with the EditText). This has been previously
reported to Google's AOSP bug tracker which provides more insight into this problem
https://code.google.com/p/android/issues/detail?id=82586 (closed Feb '15)
There are some workarounds to this issue, but the most practical suggestions that
keep the previously mentioned layout are to use a ListView or to extend EditText
or LinearLayout Manager (which either cause problems in themselves, don't work,
or both).
The solution used here simply avoids the problem all together by not nesting an
EditText in a RecyclerView. When an EditText is needed, the user is prompted with
an AlertDialog. It's not the best UX, but it's the most practical one for now.
10/8/15
*/
TextInputLayout inputLayout = new TextInputLayout(mContext);
AppCompatEditText editText = new AppCompatEditText(mContext);
editText.setInputType(mEnumeratedRule.getInputType());
inputLayout.addView(editText);
Resources res = mContext.getResources();
String type = res.getStringArray(R.array.auto_plist_types)[getSelectedType()];
String match = res.getString(mEnumeratedRule.getNameRes()).toLowerCase();
AlertDialog valueDialog = new AlertDialog.Builder(mContext)
.setMessage(type + " " + match)
.setView(inputLayout)
.setNegativeButton(R.string.action_cancel, null)
.setPositiveButton(R.string.action_done,
(dialog, which) -> {
String value = editText.getText().toString().trim();
if (editText.getInputType() == InputType.TYPE_CLASS_NUMBER) {
// Verify the input if this rule needs a numeric value
if (TextUtils.isDigitsOnly(value)) {
mFactory.setValue(value);
} else {
// If the user inputted something that's not a number, reset it
mFactory.setValue("0");
}
} else {
mFactory.setValue(value);
}
apply();
notifyPropertyChanged(BR.valueText);
})
.create();
valueDialog.getWindow().setSoftInputMode(SOFT_INPUT_STATE_VISIBLE);
valueDialog.show();
int padding = (int) mContext.getResources().getDimension(R.dimen.alert_padding);
((View) inputLayout.getParent()).setPadding(
padding - inputLayout.getPaddingLeft(), 0,
padding - inputLayout.getPaddingRight(), 0);
editText.setText(mFactory.getValue());
editText.setSelection(mFactory.getValue().length());
editText.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == KeyEvent.KEYCODE_ENDCALL) {
valueDialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
}
return false;
});
}