实验二任务1打招呼
来源:互联网 发布:rcpp软件 编辑:程序博客网 时间:2024/06/06 03:05
实验运行效果图:
mainactivity.java代码如下:
package com.example.mfc;import android.app.Activity;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;public class MainActivity extends Activity{private Button button;private EditText eT1;protected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button = (Button) this.findViewById(R.id.button);eT1 = (EditText) findViewById(R.id.eT1);button.setOnClickListener(new View.OnClickListener(){@Overridepublic void onClick(View v){String name = eT1.getText().toString();View layout = LayoutInflater.from(MainActivity.this).inflate(R.layout.toast, null);Toast toast = new Toast(MainActivity.this);TextView textView = (TextView) layout.findViewById(R.id.text);textView.setText("holle !!!!" + name);toast.setDuration(Toast.LENGTH_LONG);toast.setView(layout);toast.show();}});}}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:background="@drawable/bg" tools:context="com.example.b.shiyaner.renwuyi.dazhaohu.MainActivity" > <EditText android:id="@+id/eT1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="37dp" android:layout_marginTop="120dp" android:background="@android:drawable/edit_text" android:drawableLeft="@drawable/name" android:ems="10" android:hint="@string/et1" > <requestFocus /> </EditText><Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/eT1" android:layout_centerHorizontal="true" android:layout_marginTop="77dp" android:text="@string/bu2" /></RelativeLayout>
toast.xml代码如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#AA6666" android:orientation="horizontal" android:padding="8dp" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dp" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textColor="#114499" /></LinearLayout>Andriodmanifest.xlm代码如下:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mfc" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.mfc.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
0 0
- 实验二任务1打招呼
- 实验二 任务1 打招呼
- 实验任务1 打招呼
- 实验二.任务一.打招呼
- 实验二--任务一--打招呼
- 实验二 任务一 打招呼APP
- 实验二——任务一——打招呼
- 任务1---打招呼
- 任务1---打招呼
- 安卓任务二打招呼
- Android实验任务——打招呼
- 初学移动开发技术_实验二_任务一_打招呼
- 安卓学习 实验二任务一 ——————打招呼
- 实验一 Toast 打招呼
- 任务一,打招呼。
- 实验任务二
- 实验二任务一
- 实验二-任务一
- Classes and Structures
- UVa - 514 - Rails(栈-stack)
- C语言 1~100 所有整数中出现多少次数字 9
- 第4周项目3-并联电阻
- AndroidStudio导入一个AndroidStudio工程作为一个Library Module
- 实验二任务1打招呼
- TCP发送源码学习(3)--tcp_transmit_skb
- 广义表的基本实现
- 设计模式
- struts2.5以上 报方法不允许错误
- property not initialized at super.init call
- anaconda安装opencv
- (排列生成算法)枚举排列的两种方法:递归枚举和next_permutation (使用多用next_permutation)
- as plugin GsonFormat