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);
}
}
静态的adapter
最新推荐文章于 2018-07-13 15:02:33 发布