简体   繁体   中英

I am getting error in setContentView

I want to call another activity but I am getting error.

public class Type extends AppCompatActivity {

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

Above is my code and in setContentView activity_types is red . If I remove the package name activity_types becomes normal and R becomes red.

I tried to rebuild the project and even clean the project but still I am getting the same error. In the manifest file also it is showing error in the activity tag. The error is that in the android name the class name .Type is turning red and gradle is showing to validate resource reference inside XML files.I tried to sync with gradle but still I am getting the error.

Yes because you are using "Type" as name for the activity class name. This is prohibited just because this name class has been defined from Sdk: https://developer.android.com/reference/android/renderscript/Type.html

You just try to change the class name :)

Try this.. It will work:

package yourPackgeName;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;



import java.util.Timer;
import java.util.TimerTask;

public class FlashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //hide_notification_bar
    HideNotificationBar hideNotificationBar = new    HideNotificationBar(FlashScreen.this);
    hideNotificationBar.hideNotificationBar();

    //timer
    new Timer().schedule(new TimerTask() {
        public void run() {
            startActivity(new Intent(FlashScreen.this, NewActivity.class));
        }
    }, 3000);
}
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM