textview、button、edittext---->简易登录界面
什么是textview、button、edittext讲解属性、设置优化登录界面
背景设置外框和圆角实现具体功能
button跳转【基本步骤】 两个activity跳转前界面—>跳转后界面声明控件–找到控件–实现跳转 匹配对应用户名和密码–只讲一种方法,因为实际操作时通过插卡来实现,所以这里没有必要复杂化 获取edittest里面的用户名和密码与规定进行匹配成功则进行跳转优化之Toast讲解
一般底部弹出
Toast.makeText(getApplicationContext(),"Toast",Toast.LENGTH_SHORT).show();居中弹出
首先将toast的内容找到
设置这个toast的布局
进行show
Toast toastCenter = Toast.makeText(getApplicationContext(),"居中Toast",Toast.LENGTH_SHORT);//没有show toastCenter.setGravity(Gravity.CENTER,0,0); toastCenter.show();封装好的类**建议以后用这个
package com.example.t04.util; import android.content.Context; import android.widget.Toast; //进行一个简单的封装 //现在可以不用封装 public class ToastUtil { public static Toast mToast; public static void showMsg(Context context, String msg){ if ((mToast == null)){ mToast = Toast.makeText(context,msg,Toast.LENGTH_LONG); }else { mToast.setText(msg); } mToast.show(); } }scrollview
与linearlayout不同的是,这个布局可以滑动,适合屏幕长度显示不完的界面注意点—除了设置orientation之外,scrollview里面只能有一个主要控件解决办法就是用一个总的linearlayout盛放所有控件需要注意的是 如果orientation是horizontal,则宽度应该设置为wrap_content如果orientation是vertical,则高度应该设置为wrap_contentradiobutton
radiogroup–radiobutton
<RadioGroup android:id="@+id/rg_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginLeft="60dp"> <RadioButton android:id="@+id/rb_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="男" android:textSize="20sp" android:textColor="#000000" android:checked="true" /> <RadioButton android:id="@+id/rb_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" android:textColor="#000000" android:textSize="20sp"/> </RadioGroup>checkbox
<CheckBox android:id="@+id/cb_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ios" android:textSize="20sp" android:layout_below="@id/cb_1" android:paddingLeft="10dp"/>对应监听事件
mCb5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Toast.makeText(CheckBoxActivity.this,isChecked?"选中":"未选中",Toast.LENGTH_SHORT).show(); } }); mRg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override //监听事件 public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton) group.findViewById(checkedId); Toast.makeText(RadioButtonActivity.this,radioButton.getText(),Toast.LENGTH_SHORT).show(); } });