总结

1.获取布局中的子view:
		for (int i = 0; i < layout.getChildCount(); i++) {
			View layout = layout.getChildAt(i);
			if (layout instanceof LinearLayout) {
				LinearLayout ll = (LinearLayout) layout;
				int layoutCount = ll.getChildCount();
				for (int j = 0; j < layoutCount; j++) {
					View cv=(View)ll.getChildAt(j);
					if(cv instanceof TextView){
						cv.setOnClickListener(linstener);
					}

				}
			}
		}

第一个for循环遍历所有的子view

如果子view是一个布局,则第二个for循环遍历其子view


2.三种方法获取LayoutInflater对象:

1) 由LayoutInflater的静态函数:from(Context context) 获取:

static LayoutInflater from(Context context);

LayoutInflater inflater = LayoutInflater.from(this);    

View view=inflater.inflate(R.layout.ID, null);     

//或写成:     

View view=LayoutInflater.from(this).inflate(R.layout.ID, null);   

2) 由服务获取:

LayoutInflater inflater = (LayoutInflater)context.getSystemService     
 (Context.LAYOUT_INFLATER_SERVICE);
 


3)

调用Activity的getLayoutInflater() 函数获取LayoutInflater 对象。


3.自定义控件onMeasure方法中MeasureSpec.getMode(widthMeasureSpec)返回的Mode值

如果向自定义控件添加的子view是fill_parent的话,返回android.view.View.MeasureSpec.UNSPECIFIED

如果向自定义控件添加的子view是wrap_content的话,返回android.view.View.MeasureSpec.AT_MOST

如果向自定义控件添加的子view指定了大小的话,返回android.view.View.MeasureSpec.EXACTLY


4.Layout gravity我的理解是当前组件对父组件的位置,而gravity是当前组件的内容对当前组件的位置。


5.在继承一些adapter时候,重写getview方法,

if (convertView == null) {
                LayoutInflater layoutInflater = getLayoutInflater();
                convertView = layoutInflater.inflate(R.layout.account_entry, parent, false);
            }

可以利用convertView.findViewById方法,获取account_entry布局中的控件。最后返回convertView。


6.However, instead of applying an OnClickListener to the button in your activity, you can assign a method to your button in the XML layout, using the android:onClick attribute.这句话的意思是,代替activity中button的OnClickListener方法,你可以在XML布局的button属性里注册个方法,使用android:onClick属性。如下:

<Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="@string/self_destruct"
     android:onClick="selfDestruct" />

在activity中在写:

public void selfDestruct(View view) {
     // Kabloey
 }
 
7.android 连接sharepoint     http://www.robertkuzma.com/2011/07/manipulating-sharepoint-list-items-with-android-java-and-ntlm-authentication/
 


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值