59、微信-我-设置SettingActivity

59、微信-我-设置SettingActivity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<include layout="@layout/layout_title" />


<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txt_usersafe"
style="@style/TxtTitle"
android:textSize="16sp"
android:gravity="center_vertical"
android:background="@drawable/setting_item_selector"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:layout_marginTop="20dp"
android:drawableRight="@drawable/right"
android:text="账号安全" />
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />




<TextView
android:id="@+id/txt_msgtip"
style="@style/TxtTitle"
android:textSize="16sp"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:background="@drawable/setting_item_selector"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:drawableRight="@drawable/right"
android:text="新消息通知" />
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />




<TextView
android:id="@+id/txt_yinsi"
style="@style/TxtTitle"
android:textSize="16sp"
android:gravity="center_vertical"
android:background="@drawable/setting_item_selector"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:drawableRight="@drawable/right"
android:text="隐私" />
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />
<TextView
android:id="@+id/txt_tongyong"
style="@style/TxtTitle"
android:textSize="16sp"
android:gravity="center_vertical"
android:background="@drawable/setting_item_selector"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:drawableRight="@drawable/right"
android:text="通用" />
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />

<TextView
android:id="@+id/txt_about"
style="@style/TxtTitle"
android:textSize="16sp"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:background="@drawable/setting_item_selector"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:drawableRight="@drawable/right"
android:text="关于微信" />
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />

<LinearLayout
android:gravity="center"
android:padding="20.0dip"
android:layout_width="fill_parent"
android:layout_height="80.0dip">
<Button
android:textColor="@color/white"
android:id="@+id/btnexit"
android:background="@drawable/btn_bg_red2"
android:padding="10.0dip"
android:layout_width="fill_parent"
android:layout_height="40.0dip"
android:text="退出登录" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

布局设计可以借鉴,代码比较简单:
public class SettingActivity extends BaseActivity implements View.OnClickListener {

private TextView txt_title, txt_tip;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
findViewById();
initViews();
setOnListener();
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
}

private void findViewById() {
findViewById(R.id.img_back).setVisibility(View.VISIBLE);
findViewById(R.id.txt_right).setVisibility(View.GONE);
txt_title = (TextView) findViewById(R.id.txt_title);
txt_title.setText("设置");
}

private void initViews() {
}

private void setOnListener() {
findViewById(R.id.img_back).setOnClickListener(this);
findViewById(R.id.btnexit).setOnClickListener(this);
findViewById(R.id.txt_msgtip).setOnClickListener(this);
findViewById(R.id.txt_usersafe).setOnClickListener(this);
findViewById(R.id.txt_yinsi).setOnClickListener(this);
findViewById(R.id.txt_about).setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.img_back:
Utils.finish(SettingActivity.this);
break;
case R.id.txt_about:
Utils.start_Activity(SettingActivity.this, WebViewActivity.class,
new BasicNameValuePair(Constants.Title, "关于微信"),
new BasicNameValuePair(Constants.URL,
"https://github.com/motianhuo/wechat"));
break;

case R.id.btnexit:
EMChatManager.getInstance().logout();// 退出环信聊天
Utils.RemoveValue(context, Constants.LoginState);
Utils.RemoveValue(context, Constants.UserInfo);
Utils.RemoveValue(context, Constants.NAME);
Utils.RemoveValue(context, Constants.PWD);
App.getInstance2().exit();
Utils.start_Activity(this, LoginActivity.class);
break;
default:
break;
}
}

@Override
protected void initControl() {
// TODO Auto-generated method stub
}

@Override
protected void initView() {
// TODO Auto-generated method stub
}

@Override
protected void initData() {
// TODO Auto-generated method stub
}

@Override
protected void setListener() {
// TODO Auto-generated method stub
}

}

59、微信-我-设置SettingActivity

上一篇:微信验证及自动回复


下一篇:微信小程序双向绑定