You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.4 KiB

package com.example.Cat.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.example.Cat.R;
public class UserActivity extends Activity implements View.OnClickListener{
private ImageView userIconImage;
public String username;
Button button;
private TextView usernameText;
private LinearLayout usernameLine, userSettingLine,userProductLine;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_user);
init();
}
/**
* 组件初始化
*/
private void init() {
userIconImage = findViewById(R.id.user_icon);
usernameText = findViewById(R.id.user_username);
usernameLine = findViewById(R.id.user_userMsg);
userSettingLine = findViewById(R.id.user_setting);
userProductLine = findViewById(R.id.user_product);
userProductLine.setOnClickListener(this);
userSettingLine.setOnClickListener(this);
button=findViewById(R.id.exit);
button.setOnClickListener(this);
setData();
}
/**
* 组件赋值
*/
private void setData() {
Intent intent = UserActivity.this.getIntent();
username = intent.getStringExtra("username");
usernameText.setText(String.format("%s", username));
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.user_setting:
Log.i("message", "onClick: 111112222222222211");
Intent intent3 = new Intent(this, UserMessageActivity.class);
intent3.putExtra("username",username);
Log.i("message", "onClick: 11111111111");
startActivity(intent3);
break;
case R.id.user_product:
Intent intent2 = new Intent(this, GoodsActivity.class);
startActivity(intent2);
break;
case R.id.exit:
Intent intent4 = new Intent(this, MainActivity.class);
startActivity(intent4);
break;
}
}
}