當前位置: 首頁>>代碼示例>>Java>>正文


Java EditText.setText方法代碼示例

本文整理匯總了Java中android.widget.EditText.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.setText方法的具體用法?Java EditText.setText怎麽用?Java EditText.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: numberDecimal

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 自動補齊 0 或者 小數點
 *
 * @param mContent EditText
 * @param mDecimal 小數位數
 */
private void numberDecimal(EditText mContent, int start, int count, int mDecimal) {
    String val = mContent.getText().toString();
    if (StringUtils.isEmpty(val))
        return;
    int index;
    if ((index = val.indexOf(".")) != -1) {
        if (index == 0) {
            val = "0" + val;
            mContent.setText(val);
            mContent.setSelection(val.length());
            return;
        }
        if (val.substring(index + 1).length() > mDecimal) {
            mContent.setText(val.substring(0, start));
            mContent.setSelection(val.length() - count);
        }
    } else {
        if ("0".equals(val)) {
            val += ".";
            mContent.setText(val);
            mContent.setSelection(val.length());
        }
    }
}
 
開發者ID:abook23,項目名稱:godlibrary,代碼行數:31,代碼來源:EditTextWatcher.java

示例2: EditProductFeatureDialog

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * @param product Product that the feature belongs to
 * @param feature Feature that's being edited
 * @param context Activity context
 * @param onFeatureChanged Callback that's called when the feature is changed
 */
public EditProductFeatureDialog(final Product product,
                                final ProductFeature feature,
                                Context context,
                                final CustomCallback onFeatureChanged) {
    super(context,
            R.layout.dialog_edit_product_feature,
            "Edit feature");

    final EditText editTextLevel = (EditText) findViewById(R.id.editTextFeatureLevel);
    String stringCurrentLevel = "" + product.getLevelOfAFeature(feature);
    editTextLevel.setText(stringCurrentLevel);

    TextView textView = (TextView) findViewById(R.id.textViewFeatureName);
    textView.setText(feature.getName());

    setOkAction(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            product.addFeature(feature, Integer.parseInt(editTextLevel.getText().toString()));
            onFeatureChanged.callBack();
            dismiss();
        }
    });
}
 
開發者ID:zak0,項目名稱:AppTycoon,代碼行數:31,代碼來源:EditProductFeatureDialog.java

示例3: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calc_attenuation);
    Intent intent = getIntent();
    fEnergyList = intent.getDoubleArrayExtra(DisplayMaterialActivity.ATTEN_ENERGY);
    fCoeffList = intent.getDoubleArrayExtra(DisplayMaterialActivity.ATTEN_COEFF);
    fDensity = intent.getDoubleExtra(SearchOptionSelect.SEARCH_OBJECT_DENSITY, 0.0);
    EditText editTextDensity = (EditText) findViewById(R.id.editTextDensity);
    editTextDensity.setText(Double.toString(fDensity));
}
 
開發者ID:JW1992,項目名稱:NISTGammaSearch,代碼行數:12,代碼來源:CalcAttenuationActivity.java

示例4: handleEmoticonText

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 處理帶表情的文本(顯示表情符號)
 *
 * @param editText
 * @param content
 * @param context
 */
public static void handleEmoticonText(EditText editText, String content, Context context) {
    SpannableStringBuilder sb = new SpannableStringBuilder(content);
    String regex = "\\[(\\S+?)\\]";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(content);
    Iterator<Emoticon> iterator;
    Emoticon emoticon = null;
    while (m.find()) {
        iterator = emoticonList.iterator();
        String tempText = m.group();
        while (iterator.hasNext()) {
            emoticon = iterator.next();
            if (tempText.equals(emoticon.getContent())) {
                //轉換為Span並設置Span的大小
                sb.setSpan(new VerticalImageSpan(context,
                                decodeSampledBitmapFromResource(context.getResources(),
                                        emoticon.getImageUri(), dip2px(context, 16), dip2px(context, 16))),
                        m.start(), m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            }
        }
    }
    editText.setText(sb);
    editText.setSelection(sb.length());
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:33,代碼來源:EmoticonUtils.java

示例5: setEtText

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 設置 {@link EditText} 文本,並且移動光標到末尾.
 *
 * @param et   {@link EditText}
 * @param text 文本
 */
public static void setEtText(EditText et, CharSequence text)
{
    et.setText(text);
    //這裏進行修改,通過text.length() 設置的 Selection 有錯誤
    et.setSelection(et.getText().length());
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:13,代碼來源:ViewTool.java

示例6: onCreateDialogView

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
	View root = super.onCreateDialogView();
	mText = (EditText)root.findViewById(R.id.numberpicker_edit);
	mText.setText(""+this.getPersistedInt(0));
	return root;
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:8,代碼來源:NumberPickerPreference.java

示例7: addSecurityQuestion

import android.widget.EditText; //導入方法依賴的package包/類
private void addSecurityQuestion(SecurityQuestionModel securityQuestion) {
    _logger.Debug("addSecurityQuestion");

    final EditText questionEditText = new EditText(_context);
    final EditText answerEditText = new EditText(_context);

    final ArrayList<EditText> editPair = new ArrayList<>();
    editPair.add(questionEditText);
    editPair.add(answerEditText);

    final Button removeSecurityQuestions = new Button(_context);
    removeSecurityQuestions.setBackgroundColor(COLOR_BLACK_MAX_ALPHA);
    removeSecurityQuestions.setText("X");
    removeSecurityQuestions.setGravity(Gravity.END);
    removeSecurityQuestions.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            _securityQuestionEditTextList.remove(editPair);
            _securityButtonList.remove(removeSecurityQuestions);

            _linearLayoutSecurityQuestions.removeView(questionEditText);
            _linearLayoutSecurityQuestions.removeView(answerEditText);
            _linearLayoutSecurityQuestions.removeView(removeSecurityQuestions);
        }
    });

    _linearLayoutSecurityQuestions.addView(removeSecurityQuestions);
    _linearLayoutSecurityQuestions.addView(questionEditText);
    _linearLayoutSecurityQuestions.addView(answerEditText);

    _securityQuestionEditTextList.add(editPair);
    _securityButtonList.add(removeSecurityQuestions);

    if (securityQuestion != null) {
        questionEditText.setText(securityQuestion.GetQuestion());
        answerEditText.setText(securityQuestion.GetAnswer());
    }
}
 
開發者ID:GuepardoApps,項目名稱:PasswordSafe-AndroidClient,代碼行數:39,代碼來源:AddEditViewController.java

示例8: showInputedError

import android.widget.EditText; //導入方法依賴的package包/類
/**字符不合法提示(et == null ? toast : hint)
 * @param context
 * @param et
 * @param string
 * @return
 */
public static boolean showInputedError(Activity context, EditText et, String string) {
	if (context == null || StringUtil.isNotEmpty(string, false) == false) {
		Log.e(TAG, "showInputedError  context == null || et == null || StringUtil.isNotEmpty(string, false) == false >> return false;");
		return false;
	}
	if (et == null) {
		Toast.makeText(context, StringUtil.getTrimedString(string), Toast.LENGTH_SHORT).show();
	} else {
		et.setText("");
		et.setHint(string);
		et.setHintTextColor(context.getResources().getColor(R.color.red));
	}
	return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:EditTextUtil.java

示例9: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Intent intent = getIntent();
    if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
            resultListView, false);
    resultListView.addHeaderView(headerView);
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:37,代碼來源:SearchBookContentsActivity.java

示例10: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_login);

	loginTimes = -1;

	Bundle bundle = getIntent().getExtras();
	strEmail = bundle.getString(AppConstants.Email);

	// 使用全局變量的方式傳值
	CinemaBean cinema = GlobalVariables.Cinema;
	if (cinema != null) {
		cinemaName = cinema.getCinemaName();
	} else {
		cinemaName = "";
	}

	etEmail = (EditText) findViewById(R.id.email);
	etEmail.setText(strEmail);
	etPassword = (EditText) findViewById(R.id.password);

	// 登錄事件
	Button btnLogin = (Button) findViewById(R.id.sign_in_button);
	btnLogin.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			gotoLoginActivity();
		}
	});

	// 獲取2個MobileAPI,獲取天氣數據,獲取城市數據
	loadWeatherData();
	loadCityData();
}
 
開發者ID:BaoBaoJianqiang,項目名稱:AndroidNetwork,代碼行數:36,代碼來源:LoginActivity.java

示例11: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_convert_code);

    // initialize renderer
    converter = MongolCode.INSTANCE;

    etCodeWindow = (EditText) findViewById(R.id.etCodeWindow);
    etCodeWindow.setText("ᠮᠤᠩᠭᠤᠯ"); // Mongol
}
 
開發者ID:suragch,項目名稱:mongol-library,代碼行數:12,代碼來源:ConvertCodeActivity.java

示例12: showEditTextWarning

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 檢測EditText內容是否為空,若為空則進行警告提醒
 *
 * @param et
 * @param msg
 * @return
 */
public static boolean showEditTextWarning(EditText et, String msg) {
    if (TextUtils.isEmpty(et.getText())) {
        et.setError(msg);
        et.requestFocus();
        et.setText("");
        return true;
    }
    return false;
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:17,代碼來源:DialogUtil.java

示例13: setNumber

import android.widget.EditText; //導入方法依賴的package包/類
private void setNumber(View row, String number) {
    final EditText numberEdit = (EditText) row.findViewById(R.id.edit_number);
    numberEdit.setText(number);
    if (number == null || number.isEmpty()) {
        numberEdit.postDelayed(new Runnable() {
            @Override
            public void run() {
                numberEdit.requestFocus();
            }
        }, 100);
    }
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:13,代碼來源:AddOrEditContactFragment.java

示例14: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    balanceTxt = (EditText)findViewById(R.id.balanceTxt);
    riskTxt = (EditText)findViewById(R.id.riskTxt);
    startDateButton = (Button)findViewById(R.id.setStartDate);
    endDateButton = (Button)findViewById(R.id.setEndDate);

    balanceTxt.setText(String.valueOf(app.getInput().balance));
    riskTxt.setText((String.valueOf(app.getInput().risk)));
    startDateButton.setText(App.current.getInput().startDate.getTime().toString());
    endDateButton.setText(App.current.getInput().endDate.getTime().toString());
}
 
開發者ID:dv-lebedev,項目名稱:pair-trading-for-android,代碼行數:16,代碼來源:MainActivity.java

示例15: createEditTextAtIndex

import android.widget.EditText; //導入方法依賴的package包/類
private void createEditTextAtIndex(String text, int index) {
    EditText e = createEditText("", dip2px(10));
    e.setText(text);
    allLayout.addView(e, index);
}
 
開發者ID:appteam-nith,項目名稱:Nimbus,代碼行數:6,代碼來源:EditorView.java


注:本文中的android.widget.EditText.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。