|
操作很多个textview,如果都 |
|
|
#1 |
XUtils有个视图注入,你参考着自己写一个把
|
|
30分
#2 |
你可以使用ViewGroup把所有的子控件循环得到。
ViewGroup vg = (ViewGroup) findViewById( R.id.xxx);
for ( int i = 0; i < vg.getChildCount(); i++ ) {
TextView textView = (TextView) vg.getChildAt( i );
}
|
|
10分
#3 |
不知道你想要多简单。
可以写一个BaseActivity,让所有Activity都继承BaseActivity。
package com.jonathan.demo.patrol;
import android.app.Activity;
import android.view.View;
public class BaseActivity extends Activity {
@SuppressWarnings("unchecked")
public final <T extends View> T getView(int id) {
try {
return (T) findViewById(id);
} catch (ClassCastException ex) {
throw ex;
}
}
}
然后可以 btnLogin = getView(R.id.btnLogin); |