首页 > 其他分享 >2023/3/9每日总结

2023/3/9每日总结

时间:2023-03-11 10:36:02浏览次数:45  
标签:总结 layout 每日 content 2023 wrap import android id

跳转的实现

MainActivity.class

package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv=findViewById(R.id.tv);
tv.setText("你好,世界!");

Button bt=findViewById(R.id.button);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(MainActivity.this,MainActivity2.class);
startActivity(intent);
}
});
}
}


MainActivity2.class
package com.example.myapplication;

import android.os.Bundle;
import android.view.Menu;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activiey_main2);
}
}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello world">
</TextView>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="跳转">

</Button>

</LinearLayout>

activiey_main2.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text2">


</TextView>


</LinearLayout>






标签:总结,layout,每日,content,2023,wrap,import,android,id
From: https://www.cnblogs.com/lklyouhouhou/p/17205383.html

相关文章

  • Photoshop 2023 (ps 2023) for Mac v24.0激活版
    Photoshop 2023是一款图像处理软件。Photoshop主要处理以像素所构成的数字图像。使用其众多的编修与绘图工具,可以有效地进行图片编辑工作。ps有很多功能,在图像、图形、文字......
  • 2023/3/8每日总结
    同时展示文本与图像>同时展示文本与图像的可能途径包括:o(1)利用LinearLayout对lmageView和TextView组合布局(2)通过按钮控件Button的drawable***属性设置文本周围的图标......
  • Shell总结
    grep-i不区分大小写-c统计包含匹配的行数-n输出行号-v反向匹配-m限制结果数量 &后台执行,关闭会话终端后不再运行nohu......
  • 多媒体技术 2023-03-11
    音频的获取与处理2.1声音的基础知识声音的三个要素是音调、音强和音色。音调是指声音的高低,由频率决定。高频率的声音听起来高,低频率的声音听起来低。音乐中按音阶来表......
  • 总结20230310
    今日上了计算机网络、概率论、实用英语阅读与翻译、web开发技术、数学建模B。计算机网络讲到了第三章--数据链路层;概率论开启了第二章,讲的离散型随机变量;实用英语阅读与......
  • 2023.10 聊天机器人
    1966年,麻省理工学院人工智能实验室的德裔美国计算机科学家约瑟夫·维森鲍姆(JosephWeizenbaum)开发了历史上第一个聊天机器人——Eliza,是一个完全基于规则的聊天机器......
  • 2023.3.10
    基于Python语言gdal等模块实现遥感影像栅格数据的读取,以及基于质量评估(QA)波段实现栅格像元筛选与掩膜的全部操作。而在本文,我们依据前述这一篇博客的代码,结合大家更为熟悉......
  • HO引擎近况20230310
    这几个月冒出来好几件事上个月我有两次想起来写随笔了,但一转眼就忘了媳妇怀孕10周,孩子没发育出来就完了要搬家,找房子,我们自己收拾东西,等待房东收拾东西摩托车拆保......
  • 2023.3.10
    html头部Script插入脚本(JavaScript)```html<script>alert(1)</script>```样式文件(css)```html<style>body{background-color:greenyellow;}</style>......
  • 2023 GDKOI 游记
    2023GDKOI游记DAY\(0\)广东省重点中学信息学冬令营,好高大上的样子(看了一眼参赛的名单,耀华、中山纪念、深中的大佬都来了,感觉自己会被薄纱,本蒟蒻瑟瑟发抖了,话说六中的......