を伸ばしながら、私はLinearLayout
を延長している私のクラスを持って更新していません。のTextViewの値はのLinearLayout
コードは以下のようにスニペット:
class MyLinearLayout extends LinearLayout{
static TextView txt;
static Button btn;
static LayoutInflater inflater;
public MyLinearLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
View.inflate(context, R.layout.displayinfo, this);
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
super.onLayout(changed, l, t, r, b);
}
public void change(){
View view =inflater.inflate(R.layout.displayinfo, null);
//Button btn = (Button) inflate(context, R.id.btn, null);
txt = (TextView) view.findViewById(R.id.textView1);
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
txt.setText("Changed");
}
};
//view.refreshDrawableState();
}
@Override
protected void onDraw(Canvas canvas) {
change();
}
}
をしかしonDraw()
時に値が変更取得されていない - >change()
メソッドが呼び出さなっています。 私はWindowManager
に、このビューを追加しています。私は基本的にarray
から値を更新する必要があり、この拡張されたビューで
。しかし問題は、ループを連続的に呼び出す方法です。 invalidate()
を呼び出すと、私は継続的にそれを呼び出すことができますが、それはビューは、ユーザーが実際にView
を見ることができないので、高速リフレッシュを取得しますだけでなく、CPUの使用率が増加します。
ので、基本的に私は2つの問題を抱えている:
1. TextView
上記のコードに更新され得ていませんか?
は2.How我々は基本的に連続してinvalidate()
メソッドを呼び出すことなく、ビューの値を更新していますか?事前
。しかし、それは動作しません。 ハンドラを脇に置いておくと、ビュー内のデータをリフレッシュする他の方法は何ですか? – Robust