本文整理匯總了Java中android.widget.EditText.setTag方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.setTag方法的具體用法?Java EditText.setTag怎麽用?Java EditText.setTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setTag方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateOneEditText
import android.widget.EditText; //導入方法依賴的package包/類
/**
* Takes care of styling the editText passed in the param.
* tag is the index of the editText.
*
* @param styleEditText
* @param tag
*/
private void generateOneEditText(EditText styleEditText, String tag) {
params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
filters[0] = new InputFilter.LengthFilter(1);
styleEditText.setFilters(filters);
styleEditText.setLayoutParams(params);
styleEditText.setGravity(Gravity.CENTER);
styleEditText.setCursorVisible(mCursorVisible);
if (!mCursorVisible) {
styleEditText.setClickable(false);
styleEditText.setHint(mHint);
styleEditText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
mDelPressed = false;
return false;
}
});
}
styleEditText.setBackgroundResource(mPinBackground);
styleEditText.setPadding(0, 0, 0, 0);
styleEditText.setTag(tag);
styleEditText.setInputType(getKeyboardInputType());
styleEditText.addTextChangedListener(this);
styleEditText.setOnFocusChangeListener(this);
styleEditText.setOnKeyListener(this);
}
示例2: createEditText
import android.widget.EditText; //導入方法依賴的package包/類
private EditText createEditText(String hint, int Padding) {
EditText editText = (EditText) inflater.inflate(R.layout.item_edittext, null);
editText.setTag(viewTag++);
editText.setOnFocusChangeListener(focusChangeListener);
editText.setOnKeyListener(keyListener);
editText.setPadding(dip2px(EDIT_PADDING_TOP), Padding, dip2px(EDIT_PADDING_TOP), 0);
editText.setHint(hint);
return editText;
}
示例3: createEditText
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 生成文本輸入框
*/
public EditText createEditText(String hint, int paddingTop) {
EditText editText = (EditText) inflater.inflate(R.layout.hyper_edit_text, null);
editText.setOnKeyListener(keyListener);
editText.setTag(viewTagIndex++);
editText.setPadding(0, paddingTop, 0, paddingTop);
editText.setHint(hint);
editText.setOnFocusChangeListener(focusListener);
return editText;
}
示例4: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_code_unlock);
Log.d("gaolei", "CodeUnlockActivity------------onCreate------------------");
// LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.dp2px(this, 50));
// layoutParams.setMargins(0, statusBarHeight, 0, 0);//4個參數按順序分別是左上右下
// title_layout.setLayoutParams(layoutParams);
setStatusBar();
editText1 = (EditText) findViewById(R.id.editText1);
editText2 = (EditText) findViewById(R.id.editText2);
editText3 = (EditText) findViewById(R.id.editText3);
editText4 = (EditText) findViewById(R.id.editText4);
editText5 = (EditText) findViewById(R.id.editText5);
editText6 = (EditText) findViewById(R.id.editText6);
editText1.setTag(1);
editText2.setTag(2);
editText3.setTag(3);
editText4.setTag(4);
editText5.setTag(5);
editText6.setTag(6);
// 添加 內容change listener :輸入焦點後移 + 密碼驗證
editText1.addTextChangedListener(new MyTextChangeWatcher(1));
editText2.addTextChangedListener(new MyTextChangeWatcher(2));
editText3.addTextChangedListener(new MyTextChangeWatcher(3));
editText4.addTextChangedListener(new MyTextChangeWatcher(4));
editText5.addTextChangedListener(new MyTextChangeWatcher(5));
editText6.addTextChangedListener(new MyTextChangeWatcher(6));
// del 監聽,輸入焦點前移
editText1.setOnKeyListener(keyListener);
editText2.setOnKeyListener(keyListener);
editText3.setOnKeyListener(keyListener);
editText4.setOnKeyListener(keyListener);
editText5.setOnKeyListener(keyListener);
editText6.setOnKeyListener(keyListener);
new Utils(this).showIMM();
// ShowKeyboard(editText1);
}
示例5: initViews
import android.widget.EditText; //導入方法依賴的package包/類
private void initViews() {
btnFrom = (Button) findViewById(R.id.from);
btnFrom.setOnClickListener(this);
btnTo = (Button) findViewById(R.id.to);
btnTo.setOnClickListener(this);
btnTrainNum = (Button) findViewById(R.id.trainNum); // 車次
btnTrainNum.setOnClickListener(this);
etDate = (EditText)findViewById(R.id.date);
btnDate = (Button) findViewById(R.id.btnDate); // 選擇乘車日期
btnDate.setOnClickListener(this);
btnOK = (Button) findViewById(R.id.ok);
btnOK.setOnClickListener(this);
etTravelName = (EditText) findViewById(R.id.travelName);
etTime = (EditText) findViewById(R.id.time);
btnFrom.setText(setSP.getLastFromStationKey());
btnTo.setText(setSP.getLastToStationKey());
// 取得當前日期
Calendar c = Calendar.getInstance(Locale.getDefault());
c.setTimeInMillis(System.currentTimeMillis());
intYear = c.get(Calendar.YEAR);
intMonth = c.get(Calendar.MONTH);
intDay = c.get(Calendar.DAY_OF_MONTH);
String strDate = TimeUtil.getDFormat().format(c.getTime());
etDate.setText(strDate + " " + TimeUtil.getWeek(c.getTime()));
etDate.setTag(strDate);
if (this.getIntent().getStringExtra(TRAIN_NUM) != null){
strTrainNum = this.getIntent().getStringExtra(TRAIN_NUM);
btnFrom.setText(this.getIntent().getStringExtra(START_STATION));
btnTo.setText(this.getIntent().getStringExtra(END_STATION));
intDataSource = this.getIntent().getIntExtra(DATA_SOURCE, DATA_FROM_OFFINE_DB);
if (intDataSource == DATA_FROM_OFFINE_DB){
SimpleDialogFragment
.createBuilder(
AddInfoAty.this,
getSupportFragmentManager())
.setCancelable(false)
.setRequestCode(REQUET_SET_TRAVEL_BRIEF_OF_DATA_FROM_OFFLINE_DB)
.setTitle("提示")
.setMessage("檢測到您采用離線數據快速添加數據,為保證數據準確性請您手動進行車次選擇"+SF.TIP)
.setPositiveButtonText("確定")
.show();
}
String strStartTime = getIntent().getStringExtra(EXTRA_START_TIME);
if (!TextUtils.isEmpty(strStartTime)){
try {
Date date1 = TimeUtil.getDFormat().parse(strStartTime);
strStartTime = TimeUtil.getDFormat().format(date1);
etDate.setText(strStartTime + " " + TimeUtil.getWeek(strStartTime));
etDate.setTag(strStartTime);
} catch (ParseException e) {
e.printStackTrace();
}
}
getTrains();
}
}
示例6: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_activity);
String pathFile = getIntent().getStringExtra(Commons.pathFile);
TextView tv = (TextView) findViewById(R.id.notetitle);
tv.setTextColor(Color.WHITE);
tv.setText(""+pathFile);
//Get the text file
File file = new File(pathFile);
//Read text from file
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
}
catch (IOException e) {
//You'll need to add proper error handling here
}
//Find the view by its id
EditText edit = (EditText) findViewById(R.id.note);
//Set the text
edit.setFocusable(false);
edit.setFocusableInTouchMode(false);
edit.clearFocus();
edit.setTag(edit.getKeyListener());
edit.setKeyListener(null);
edit.setText(text.toString());
edit.setTextColor(Color.DKGRAY);
}