android textviewがテキストで設定されている場合、コールバックが呼び出されますか?
1930 次
5 に答える
7
TextWatcher
TextViewでテキストの変更を監視するために、TextViewにを次のように追加します。
TextView textView=(TextView)findViewById(R.id.txtview);
textView.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
//here you will get changed text in textview
}
});
于 2012-05-21T09:11:27.060 に答える
1
それを行う別の方法は次のとおりです。
if( TextView.getText().length() != 0) {}
于 2013-08-12T04:12:14.990 に答える
0
次を使用して、TextViewにテキストがあるかどうかを簡単に確認できます。
TextView yourTextView = (TextView)findViewById(R.id.textViewID);
if(yourTextview.getText().toString().equals(""))
//it is blank
else
//it has text
于 2012-05-21T09:08:09.983 に答える
0
私の意見では、これを行うための最良の方法は次のとおりです。
if(TextView.getText == null);
于 2012-05-21T09:09:13.140 に答える
0
いいえ。実行時にユーザーがコードからテキストを設定したかどうかを確認する唯一の方法は、インスタンスを作成することです。
TextView tv = (TextView)findViewById(R.id.your_id)
このテキストにgetText()
メソッド付きのテキストがあるかどうかを確認し、最初にtextViewにテキストがあるかどうかを確認します。
于 2012-05-21T09:09:39.743 に答える