gpt4 book ai didi

java - 无法解析符号

转载 作者:行者123 更新时间:2023-12-02 04:39:18 25 4
gpt4 key购买 nike

因此,我正在编写代码,以便可以在您的应用程序中设置个人资料图像,但是我收到无法解析符号的错误。我不知道为什么或如何。

我已经提交了发生这些错误的位置,我正在使用Android Studio

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ImageButton;

import com.example.wilmar.rentacube.R;

/**
* Created by wilmar on 23-4-2015.
*/
public class Profile extends Activity {

ImageView contactImageImgView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
String Name = getIntent().getStringExtra("Name");
String eMail = getIntent().getStringExtra("Mail");
String Mobile = getIntent().getStringExtra("Mobile");


contactImageImgView = (ImageView) findViewById(R.id.imgViewContactImage);
TextView tv_Name = (TextView) findViewById(R.id.Name);
TextView tv_Mail = (TextView) findViewById(R.id.Email);
TextView tv_Mobile = (TextView) findViewById(R.id.Mobile);

tv_Name.setText(Name);
tv_Mail.setText(eMail);
tv_Mobile.setText(Mobile);

}

public void onButtonClick(View v) {
if (v.getId() == R.id.BeditProfile) {
Intent i = new Intent(Profile.this, editProfile.class);
startActivity(i);
}

}

contactImageImgView.setOnClickListener(new View.OnClickListener) //error @.setOnClickListener Cannot resolve symbol
{
public void onClick (View v){ // error @ View v, cannot resolve symbol v , expected ;
Intent intent = new Intent();
intent.setType("image*/");
intent.setAction(intent.ACTION_GET_CONTENT);
startActivityForResult(intent.createChooser(intent, "Select Profile Image"), 1);
}
}

public void onActivityResult(int reqCode, int resCode, Intent data) {
if(resCode == RESULT_OK){
if(resCode == 1)
contactImageImgView.setImageURI(data.getData());
}

}


}

最佳答案

contactImageImgView.setOnClickListener(new View.OnClickListener) //error @.setOnClickListener Cannot resolve symbol
{
public void onClick (View v){ // error @ View v, cannot resolve symbol v , expected ;
Intent intent = new Intent();
intent.setType("image*/");
intent.setAction(intent.ACTION_GET_CONTENT);
startActivityForResult(intent.createChooser(intent, "Select Profile Image"), 1);
}
}

以上代码需要位于方法内部。把它放在onCreate()里面,它就会工作。

关于java - 无法解析符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30373403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com