• 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; }
  • 相关阅读:
    Oracle 18c新特性一览
    iOS xcode缓存问题
    预编译头文件
    iOS 限制UITextField输入字符
    网络通信之 字节序转换原理与网络字节序、大端和小端模式
    iOS 库文件制作
    iOS 全屏布局
    内存问题 动态加载地址和运行时地址
    申请工作居住证政策解答
    phpsession配置
  • 原文地址:https://www.cnblogs.com/alamps/p/5208048.html
Copyright © 2020-2023  润新知