android引用链接,android – 链接本地重命名的所有引用(不更改其他文件中的引用)...

在Android应用中,遇到配置变更如屏幕尺寸改变时,尝试设置不同布局导致的‘链接本地重命名的所有引用’错误。问题出现在setContentView()调用中,可能由于导入了android.R导致。解决方案是检查并移除导入的android.R,使用项目的R文件代替。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用显示指标第一次出现错误“链接本地重命名的所有引用(不更改其他文件中的引用)”,以便所有具有id显示id的行都不会被解析.我将放置代码.帮助我.

public void onConfigurationChanged(Configuration newConfig) {

super.onConfigurationChanged(newConfig);

try{

emailForConfigChanges = emailTextBox.getText().toString().trim();

passwordForConfigChanges = passwordTextBox.getText().toString().trim();

DisplayMetrics displayMetrics = new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

switch(displayMetrics.densityDpi){

case DisplayMetrics.DENSITY_LOW:

setContentView(R.layout.login_small);

*showing error in the above line "Link all references for a local rename (does not change references in other files)"*

break;

default:

setContentView(R.layout.login);

}

} catch(Exception e){

e.printStackTrace();

}

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

ImageButton loginButton = (ImageButton) findViewById(R.id.loginButton);

loginButton.setOnClickListener(this);

ImageButton registerOrangeButton = (ImageButton) findViewById(R.id.registerOrangeButton);

registerOrangeButton.setOnClickListener(this);

TextView forgotPasswordText = (TextView) findViewById(R.id.forgotPasswordText);

forgotPasswordText.setOnClickListener(this);

passwordTextBox = (EditText) findViewById(R.id.passwordLogin);

passwordTextBox.setText(passwordForConfigChanges);

passwordTextBox.setOnKeyListener(this);

emailTextBox = (EditText) findViewById(R.id.emailLogin);

emailTextBox.setText(emailForConfigChanges);

emailTextBox.setOnKeyListener(this);

解决方法:

请检查导入部分

如果这一行 – > “import android.R;”存在你应该删除

标签:android

来源: https://codeday.me/bug/20190625/1286421.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值