菜鸟Andriod学习32——仿QQ登陆界面
来源:互联网 发布:评价公司的网站 知乎 编辑:程序博客网 时间:2024/06/09 11:53
XML文件:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:stretchColumns="0,3"
>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"
android:textSize="24sp" />
<EditText
android:id="@+id/user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:minWidth="200sp"
>
<requestFocus />
</EditText>
<TextView />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密 码"
android:textSize="24sp"/>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:minWidth="200sp"
android:inputType="textPassword" />
<TextView />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="进去" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="出来" />
<TextView />
</TableRow>
</TableLayout>
Activity_main.java文件代码:
final int NOTIFYID_1 = 123;
private String user = "rosys";
private NotificationManager notificationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Button button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText etUser = (EditText)findViewById(R.id.user);
if(!"".equals(etUser.getText())){
user = etUser.getText().toString();
}
sendNotification();
}
});
Button button2=(Button)findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
notificationManager.cancel(NOTIFYID_1);
// TODO Auto-generated method stub
// 让布局第一行显示
((TableRow)findViewById(R.id.tableRow1)).setVisibility(View.VISIBLE);
// 让布局第二行显示
((TableRow)findViewById(R.id.tableRow2)).setVisibility(View.VISIBLE);
((Button)findViewById(R.id.button1)).setText("登陆");
}
});
}
protected void sendNotification() {
// TODO Auto-generated method stub
Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setIcon(R.drawable.advise);
builder.setTitle("我的登陆状态是");
final int[]imageId = new int[]{R.drawable.img1,R.drawable.img2,
R.drawable.img3,R.drawable.img4};
final String[] title = new String[]{"伤心","happy","sad","smile"};
// 创建一个list集合
List<Map<String,Object>>listItems = new ArrayList<Map<String,Object>>();
// 通过for循环将突破ID和列表项文字放到map中,并添加到List集合中
for(int i = 0;i<imageId.length;i++){
// 实例话map对象
Map<String, Object>map = new HashMap<String, Object>();
map.put("image", imageId[i]);
map.put("title", title[i]);
listItems.add(map);
}
final SimpleAdapter adapter = new SimpleAdapter(MainActivity.this,listItems,R.layout.items,
new String[]{"title","image"},new int[]{R.id.title,R.id.image});
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Notification notify = new Notification();
notify.icon = imageId[which];
notify.tickerText=title[which];
notify.when = System.currentTimeMillis();
notify.defaults = Notification.DEFAULT_SOUND;
notify.setLatestEventInfo(MainActivity.this, user, title[which], null);
notificationManager.notify(NOTIFYID_1,notify);
// 让布局第一行不显示
((TableRow)findViewById(R.id.tableRow1)).setVisibility(View.INVISIBLE);
// 让布局第二行不显示
((TableRow)findViewById(R.id.tableRow2)).setVisibility(View.INVISIBLE);
((Button)findViewById(R.id.button1)).setText("更改登录状态");
}
});
builder.create().show();
}
效果如图:
- 菜鸟Andriod学习32——仿QQ登陆界面
- 仿qq登陆界面
- Android学习笔记(一)——仿qq聊天的welcome界面登陆的实现
- java 仿qq登陆界面
- Android仿qq登陆界面
- java仿qq登陆界面
- 仿QQ登陆客户端登陆界面
- Android 高仿QQ 登陆界面
- 仿QQ概念版的登陆界面
- 实例11:仿QQ客户端登陆界面
- android 仿QQ登陆界面实现
- 菜鸟 利用VE、截图 快速打造仿QQ绚丽界面
- android实现仿QQ登陆界面的多账号保存
- Android仿QQ微信开场导航以及登陆界面
- Android仿QQ微信开场导航以及登陆界面
- Android仿QQ微信开场导航以及登陆界面
- 《java---高仿QQ登陆界面》---完全手写
- Android仿QQ微信开场导航以及登陆界面
- make install的时候指定安装路径
- Java异常趣解
- 史上最快Android模拟器:Genymotion使用介绍
- 大数_高精度阶乘
- 使用国内镜像通过pip安装python的一些包
- 菜鸟Andriod学习32——仿QQ登陆界面
- Excel解析(一)——JXL
- 有符号数与无符号数之间运算问题
- 计算机视觉的一些测试数据集和源码站点
- JNI
- 1.3 创建一个简单的用户界面
- C++中的.hpp
- android程序员学习ios - 5 - textField初探(xcode 5.0)
- 我的2013-从GIS学生到GIS职业人的飞跃