zoukankan      html  css  js  c++  java
  • 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; }
  • 相关阅读:
    2021.10 db2转换openGauss个人工作总结及心得
    cpu 超过100%,我的排查步骤
    记美团一面,凉凉~
    Eureka挂掉,服务之间能否正常调用?
    jpa中的常用关键字
    Linux修改文件目录所属用户和组
    linux 下如何查看端口占用?
    windows 下如何查看端口占用情况?
    docker学习网站
    api接口文档生成,无需其他配置一键生成基于文本注释
  • 原文地址:https://www.cnblogs.com/alamps/p/5208048.html
Copyright © 2011-2022 走看看