Eclipse无法连接花括号

时间:2014-11-13 16:45:49

标签: android eclipse

我是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;
        }
    }

}

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

提前致谢

1 个答案:

答案 0 :(得分:3)

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

摆脱=。你可以在这里找到member variables

的精彩介绍