max max - 6 months ago 62
Android Question

setContentView(R.layout.Main); Main cannot be resolved or is not a field

This is a simple program for beginning (simple for you, not for me) eclipse. I want to change a text by clicking on a button, but it's not working.

Here is the code:

package com.example.androidcourse;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.R.layout;

public class MainActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {

Button btn = (Button) findViewById(;
final TextView text = (TextView) findViewById(;
btn.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
text.setText("New bingo...");


First just build your project. If it will not work, then delete from imports android.R.layout and use layout from your package.