gpt4 book ai didi

android - Eclipse无法连接花括号

转载 作者:行者123 更新时间:2023-11-29 17:45:45 25 4
gpt4 key购买 nike

我是 Android 编程新手,正在学习本教程:https://www.youtube.com/watch?v=pZaRNVwKAy4 .我完全按照教程进行操作,但 Eclipse 设法发现了很多错误。它说花括号不正确,但是当我选择一个时,它对应的那个会亮起并且它们都是一对。此外,Eclipse 不识别我在 onCreate 方法之前声明的变量。这是代码:

package com.example.tutorialproject;

import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;



public class TutorialOne extends Activity implements OnCheckedChangeListener{

TextView = textOut;
EditText = textIn;
RadioGroup = gravityG, styleG;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial1);

textOut = (TextView) findViewById(R.id.tvChange);
textIn = (EditText) findViewById(R.id.editText1);
gravityG = (RadioGroup) findViewById(R.id.rgGravity);
styleG = (RadioGroup) findViewById(R.id.rgStyle);
Button gen = (Button) findViewById(R.id.bGenerate);

gen.setOnClickListener(new View.OnClickListener() {

public void onClick(View v){
textOut.setText(textIn.getText());
}

});
}

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub

switch (checkedId){
case R.id.rbLeft:
textOut.setGravity(Gravity.LEFT);
break;

case R.id.rbCenter:
textOut.setGravity(Gravity.CENTER);
break;

case R.id.rbRight:
textOut.setGravity(Gravity.RIGHT);
break;
}
}

}

剪切/粘贴和清理不起作用,我已经尝试过了。任何人都知道可能是什么问题?抱歉发了这么长的帖子。

提前致谢

最佳答案

TextView = textOut;
EditText = textIn;
RadioGroup = gravityG, styleG;

去掉 =。您可以在此处找到关于 member variables 的精彩介绍。

关于android - Eclipse无法连接花括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26913993/

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