本文介绍了GOT混淆语法错误!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    RelativeLayout rl = (RelativeLayout) findViewById(R.id.imageView5);
    ImageView iv;
    RelativeLayout.LayoutParams params; //; syntax error!! over HERE, params Error too 

    iv = new ImageView(this);
    iv.setBackgroundColor(Color.YELLOW);
    params = new RelativeLayout.LayoutParams(30, 40);
    params.leftMargin = 50;
    params.topMargin = 60;
    rl.addView(iv, params);

}//} and HERE too





我做错了吗?来自

[]

推荐答案

public class MainActivity extends Activity {

    RelativeLayout rl;
    ImageView iv;
    RelativeLayout.LayoutParams params;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        r1=(RelativeLayout) findViewById(R.id.imageView5);
        iv = new ImageView(this);
        iv.setBackgroundColor(Color.YELLOW);
        params = new RelativeLayout.LayoutParams(30, 40);
        params.leftMargin = 50;
        params.topMargin = 60;
        rl.addView(iv, params);

    }


}


这篇关于GOT混淆语法错误!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 02:18