关于android 布局中诡异的AttributeSet 搜索记录

package android.widget.Demo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.widget.Toast;
import android.content.Intent;
import android.view.View.OnClickListener;
import org.xmlpull.v1.XmlPullParser;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Xml;


public class Ex07_WidgetDemoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Context mContext = this;
        XmlPullParser parser = mContext.getResources().getXml(R.layout.togglebutton_layout);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        Button btn1 = new Button(mContext, attrs, 0);
        Button btn2 = new Button(mContext, attrs);
        Button btn3= new Button(mContext);
        btn1.setText("Hello btn1!");
        setContentView(btn1);

    }
}

----------------------------------------------------------------

相关推荐