App crashing when setting new content view

后端 未结 3 1850
误落风尘
误落风尘 2021-01-24 08:26

Edit:

It seems my button styles are causing the issue.

Edit Code

buttonL.setOnTouchListener(new View.OnTouchListener() {

        public boolean          


        
相关标签:
3条回答
  • 2021-01-24 09:09

    Try this:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
    
        Thread splash=new Thread(){
            public void run(){
                try{
                    sleep(2000);
                }catch(Exception e){
                    e.printStackTrace();
                }finally{
                    startActivity(new Intent(getApplicationContext(),StartMenu.class));
                    finish();
                }
            }
        };
    
        splash.start();
    }
    

    And your Manifest.xml:

     <activity
     android:name="com.example.mapcard.Splash"
     android:label="@string/app_name" >
     <intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
    
    0 讨论(0)
  • 2021-01-24 09:10

    From logcat the problem is background of your Button. I think it's somehow big image so it overflow your memory.

    First
    Try to remove any @drawable in menu_system.xml especially android:background in Button
    Run your if it's work then you know where to look.

    Second(for workaround)
    Move your background image file to bigger folder
    from drawable to drawable-xhdpi

    0 讨论(0)
  • 2021-01-24 09:29

    I tried your code .It was working fine.I think issue is because of out of memory.Issue is with image resource ,try to set image in compressed format to avoid memory leakage.

    0 讨论(0)
提交回复
热议问题