静态的adapter

package com.cardvalue.sys.activitys;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.cardvlaue.sys.R;
import com.cardvalue.sys.common.MyApplication;
import com.cardvalue.sys.common.VarKeyNames;
import com.cardvalue.sys.widget.IosDailog;


public class ShowUserInfo extends BaseActivity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.userinfo_view);
		setHeaderFields(0, R.string.user,0,R.drawable.back, 0,0);
 
		List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();
		Map<String,Object> map = new HashMap<String,Object>();
		Map<String,Object> user = MyApplication.getApplication().getLocalCache().getMap(VarKeyNames.UserInfo);
		map.put("text1",user.get("ownerName")==null || user.get("ownerName").toString().trim().equals("")?"亲爱的用户":user.get("ownerName").toString());
		map.put("image1",R.drawable.about);
		map.put("text2", "姓名:");
		data.add(map);		

		map = new HashMap<String,Object>();
		map.put("text1",user.get("mobilePhone"));
		map.put("image1",R.drawable.phone);
		map.put("image2", "");
		map.put("text2", "手机号:");
		data.add(map);	

		map = new HashMap<String,Object>();
		if (user.get("ownerSSN")==null || user.get("ownerSSN").equals(""))
			map.put("text1","******************");
		else
		map.put("text1",user.get("ownerSSN"));
		map.put("image1",R.drawable.pwdsc);
		map.put("image2", "");
		map.put("text2", "身份证:");
		data.add(map);	

		map = new HashMap<String,Object>();
		map.put("text2","修改密码:");
		map.put("image1",R.drawable.password);
		map.put("image2", R.drawable.ic_right);
		data.add(map);	

		ListView lv = (ListView)findViewById(R.id.userinfo_list);
		SimpleAdapter sa = new SimpleAdapter(this,data,R.layout.myaccount_list_2_layout,new String[]{"text1","text2","image2"},new int[]{R.id.text2,R.id.text1,R.id.imager_1});
		lv.setDivider(null);
		lv.setAdapter(sa);
		lv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				TextView tv = (TextView)arg1.findViewById(R.id.text1);
				if (tv.getText().toString().equals("修改密码:")){
					Intent intent = new Intent(ShowUserInfo.this,ChangePwdActivity.class);
					startActivity(intent);
					ShowUserInfo.this.finish();
				}
			}
		});
 
		//按下退出键
		Button button = (Button)findViewById(R.id.button1);
		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				IosDailog.CustomAlert("退出", "退出后您将不能查看相关信息,确定要退出当前账号吗?", ShowUserInfo.this, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface arg0, int arg1) {
						cache.putString("username", "");
						cache.putString("password", "");
						cache.putString("exirDate", "");
						MyApplication.getApplication().setLogin(false);
						MyApplication.removeAll();
						Intent intent =new Intent(ShowUserInfo.this,Home.class);
						intent.putExtra("tagchang","0");
						startActivity(intent);
						arg0.cancel();
						MyApplication.removeAll();
						ShowUserInfo.this.finish();
						
					}

				}, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface arg0, int arg1) {
						arg0.cancel();
					}
				});
			}
		});
	}
	@Override
	public void goBack(View view) {
		Home.from = "outer";
		super.goBack(view);
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值