RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Android基础

1,

我们提供的服务有:网站建设、成都网站建设、微信公众号开发、网站优化、网站认证、新余ssl等。为上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的新余网站制作公司

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);#任何的项目都需要覆写父类的onCreate方法

setContentView(R.layout.activity_main);#显示出你所定义的布局,或指在当前活动中加载你所需要的布局

}

2,创造加载布局 res/layout/new/android xml file

Android基础

    android:layout_width="match_parent"//让当前元素变得和父类一样宽

    android:layout_height="match_parent"

    android:orientation="vertical" >布局是垂直的,添加文件只能垂直添加

   

        android:id="@+id/button1"//添加一个按钮

        android:layout_width="match_parent"

        android:layout_height="wrap_content"//只能包裹住文字

        android:text="Button" />

3,

       @Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏

setContentView(R.layout.first_layout);

}

4,

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏

setContentView(R.layout.first_layout);

Button button1 = (Button) findViewById(R.id.button1);

button1.setOnClickListener(new OnClickListener() {//创造一个按钮的监听器,点击会有响应,如果出现错误,点击//ctrl+shift+o即可

@Override

public void onClick(View v) {

// TODO 自动生成的方法存根

Toast.makeText(getApplicationContext(), "you clicked button1", Toast.LENGTH_SHORT).show();

}

});

}


名称栏目:Android基础
URL标题:http://sczitong.cn/article/ghecso.html