android_demo01

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android_demo01相关的知识,希望对你有一定的参考价值。

 /layout/activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <TextView
         android:id="@+id/mytext"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
        />
    <Button
        android:id="@+id/mybtn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />

</RelativeLayout>
com.example.demo01textviewbutton.MainActivity
package com.example.demo01textviewbutton; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView;
//当在/layout/activity_main.xml中加控件后,R会自动生成相应的资源文件ID public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //编写相应业务逻辑 TextView textView = (TextView) super.findViewById(R.id.mytext); textView.setText("buy big house"); Button mybutton=(Button)super.findViewById(R.id.mybtn); mybutton.setText("clink me ,xixihehehaha"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
R.java中生成以下:   
public static final class id { public static final int action_settings=0x7f080002; public static final int mybtn=0x7f080001; public static final int mytext=0x7f080000; }

 

以上是关于android_demo01的主要内容,如果未能解决你的问题,请参考以下文章

Android_demo之生成二维码

19 01 11 javascript ?????????????????????(???????????????) ??????????????????????????????(代码片段

[linux][c/c++]代码片段01

这两个代码片段有啥区别?

用片段替换某些东西

为啥此代码片段返回意外结果?