2017-01-01 90 views
0

後我創造,我已經在一個項目和閃屏和第二項目多了一個隨機的活動創建導航抽屜的應用程序。 所以我試圖合併他們。我已經設置了啓動畫面和隨機acitvity因此合併已經做好了。主要活動得到白色屏幕slpash屏幕

然後,我設置了按鈕隨機活動重定向到活動(這裏是homeActivity)但是當我點擊按鈕其得到白屏

在homeAcitivity我已經使用導航抽屜我已經提到所以我怎麼能解決上mainActivity白屏問題??? 我在這裏看到了一些問題,但我沒有得到我的解決方案....

採用了android 2.1.2 studion的gradle 2.10版本

感謝

CODE

這裏mainActivity(這裏主頁活動)

public class homeActivity extends AppCompatActivity 
implements NavigationView.OnNavigationItemSelectedListener { 
ListView list; 
String[] menutitles; 
String[] menudescriptions; 
int images[]={R.drawable.mouse, R.drawable.keyboard, R.drawable.filemanager, R.drawable.media, R.drawable.power}; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    Resources res = getResources(); 
    menutitles=res.getStringArray(R.array.titles); 
    menudescriptions=res.getStringArray(R.array.descriptions); 
    list = (ListView) findViewById(R.id.listView); 
    listadapter adptr=new listadapter(this,menutitles,images,menudescriptions); 
    list.setAdapter(adptr); 
    onclick(); 
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
    drawer.setDrawerListener(toggle); 
    toggle.syncState(); 

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
    navigationView.setNavigationItemSelectedListener(this); 
} 
public void onBackPressed() { 
     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     if (drawer.isDrawerOpen(GravityCompat.START)) { 
      drawer.closeDrawer(GravityCompat.START); 
     } else { 
      super.onBackPressed(); 
     } 
    } 

    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 
public boolean onNavigationItemSelected(MenuItem item) { 
    // Handle navigation view item clicks here. 
    int id = item.getItemId(); 

    if (id == R.id.nav_mouse) { 
     Intent intentu = new Intent("com.example.admin.pcremote.MouseActivity"); 
     startActivity(intentu); 
    } else if (id == R.id.nav_keyboard) { 
     Intent intentu = new Intent("com.example.admin.pcremote.KeyboardActivity"); 
     startActivity(intentu); 
    } else if (id == R.id.nav_filemanager) { 
     Intent intentu = new Intent("com.example.admin.pcremote.FilemanagerActivity"); 
     startActivity(intentu); 
    } else if (id == R.id.nav_media) { 
     Intent intentu = new Intent("com.example.admin.pcremote.MediaActivity"); 
     startActivity(intentu); 
    } else if (id == R.id.nav_power) { 
     Intent intentu = new Intent("com.example.admin.pcremote.PowerActivity"); 
     startActivity(intentu); 
    }else if (id == R.id.nav_send) { 
     AlertDialog.Builder builder = new AlertDialog.Builder(homeActivity.this); 
     builder.setMessage("Do You Want To Exit?").setCancelable(false) 
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
        @Override 
        public void onClick(DialogInterface dialog, int which) { 
         finish(); 
        } 
       }).setNegativeButton("No", new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which) { 
       dialog.cancel(); 
      } 
     }); 
     AlertDialog alert = builder.create(); 
     alert.setTitle("Exit!!"); 
     alert.show(); 
    } 

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
    drawer.closeDrawer(GravityCompat.START); 
    return true; 
} 

activ ity_main.xml(homeActivity)

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:openDrawer="start"> 

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:headerLayout="@layout/nav_header_main" 
    app:menu="@menu/activity_main_drawer" > 

    <include 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</android.support.design.widget.NavigationView> 

app_bar_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout   
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.example.admin.pcremote.homeActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_main" /> 
</android.support.design.widget.CoordinatorLayout> 

content_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="com.example.admin.pcremote.homeActivity" 
tools:showIn="@layout/app_bar_main"> 

<ListView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/listView" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true"> 
</ListView> 

</RelativeLayout> 

這裏是其他活動 在此我試圖導航等活動其工作,但不知道mainActivity

AlertDialog.Builder builder = new AlertDialog.Builder(ipInfo.this); 
    builder.setTitle("Warning"); 
     builder.setMessage("IP address or port number cannot be empty!!!").setCancelable(false) 
.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which) { 
        dialog.cancel(); 
         }}).setNegativeButton("Continue Anyway", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 
     Intent inst = new Intent(ipInfo.this,homeActivity.class);//here is redirection of home activity 
     startActivity(inst); 
     }}); 
     AlertDialog alert = builder.create(); 
     alert.setIcon(R.drawable.ic_error_outline_black_24dp); 
     alert.show(); 

閃屏

protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_welcome_splash); 
    getSupportActionBar().hide(); 
    Thread ssThread = new Thread(){ 
     @Override 
     public void run() { 
      try { 
       StartAnimations(); 
       sleep(3500); 
       Boolean isfirstrun = getSharedPreferences("PREFERENCES",MODE_PRIVATE).getBoolean("first",true); 
       if(isfirstrun){ 
        Intent inst = new Intent(welcome_splash.this,install_server.class); 
        startActivity(inst); 
        getSharedPreferences("PREFERENCES",MODE_PRIVATE).edit().putBoolean("first",false).commit(); 
       }else{ 
       Intent starthomeScreen = new Intent(getApplicationContext(),ipInfo.class); 
       startActivity(starthomeScreen);} 
       finish(); 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } 
     } 
    }; 
    ssThread.start(); 


} 
private void StartAnimations() { 
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha); 
    anim.reset(); 
    RelativeLayout l = (RelativeLayout) findViewById(R.id.rel_lay); 
    l.clearAnimation(); 
    l.startAnimation(anim); 

    anim = AnimationUtils.loadAnimation(this, R.anim.translate); 
    anim.reset(); 
    ImageView iv = (ImageView) findViewById(R.id.logo); 
    iv.clearAnimation(); 
    iv.startAnimation(anim); 


} 

logcat的是

01-01 16:55:22.725 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 574: Landroid/content/ContextWrapper;.getObbDirs()[Ljava/io/File; 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x1356 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.app.Activity.startPostponedEnterTransition, referenced from method com.example.admin.pcremote.homeActivity.access$super 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 249: Landroid/app/Activity;.startPostponedEnterTransition()V 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x135c 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.content.ContextWrapper.getExternalCacheDirs, referenced from method com.example.admin.pcremote.homeActivity.access$super 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 565: Landroid/content/ContextWrapper;.getExternalCacheDirs()[Ljava/io/File; 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x13ce 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.app.Activity.onEnterAnimationComplete, referenced from method com.example.admin.pcremote.homeActivity.access$super 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 145: Landroid/app/Activity;.onEnterAnimationComplete()V 
01-01 16:55:22.725 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x1411 
01-01 16:55:22.735 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 537K, 9% free 8425K/9159K, paused 2ms, total 2ms 
01-01 16:55:22.735 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 9.256MB for 1048588-byte allocation 
01-01 16:55:22.745 4495-4499/com.example.admin.pcremote D/dalvikvm: GC_CONCURRENT freed 4K, 8% free 9444K/10247K, paused 10ms+0ms, total 12ms 
01-01 16:55:22.755 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed <1K, 8% free 9444K/10247K, paused 2ms, total 2ms 
01-01 16:55:22.755 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 11.501MB for 2359308-byte allocation 
01-01 16:55:22.765 4495-4499/com.example.admin.pcremote D/dalvikvm: GC_CONCURRENT freed 0K, 7% free 11748K/12615K, paused 1ms+1ms, total 5ms 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init> 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve direct method 19953: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.widget.LinearLayout$LayoutParams.<init>, referenced from method android.support.design.widget.AppBarLayout$LayoutParams.<init> 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve direct method 19953: Landroid/widget/LinearLayout$LayoutParams;.<init> (Landroid/widget/LinearLayout$LayoutParams;)V 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x70 at 0x0000 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.widget.ArrayAdapter.getDropDownViewTheme, referenced from method com.example.admin.pcremote.listadapter.access$super 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 19710: Landroid/widget/ArrayAdapter;.getDropDownViewTheme()Landroid/content/res/Resources$Theme; 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x014a 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.widget.ArrayAdapter.setDropDownViewTheme, referenced from method com.example.admin.pcremote.listadapter.access$super 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 19720: Landroid/widget/ArrayAdapter;.setDropDownViewTheme (Landroid/content/res/Resources$Theme;)V 
01-01 16:55:22.775 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x01d4 
01-01 16:55:22.805 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 3414K, 32% free 8697K/12615K, paused 2ms, total 4ms 
01-01 16:55:22.805 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 9.084MB for 589836-byte allocation 
01-01 16:55:22.815 4495-4499/com.example.admin.pcremote D/dalvikvm: GC_CONCURRENT freed 11K, 27% free 9262K/12615K, paused 11ms+0ms, total 14ms 
01-01 16:55:22.815 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 258K, 29% free 9015K/12615K, paused 1ms, total 2ms 
01-01 16:55:22.815 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 9.808MB for 1022412-byte allocation 
01-01 16:55:22.825 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed <1K, 21% free 10013K/12615K, paused 2ms, total 2ms 
01-01 16:55:22.825 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 0K, 21% free 10013K/12615K, paused 2ms, total 2ms 
01-01 16:55:22.825 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 12.001MB for 2300412-byte allocation 
01-01 16:55:22.835 4495-4499/com.example.admin.pcremote D/dalvikvm: GC_CONCURRENT freed 0K, 18% free 12260K/14919K, paused 1ms+0ms, total 4ms 
01-01 16:55:22.845 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 1396K, 19% free 12175K/14919K, paused 2ms, total 2ms 
01-01 16:55:22.845 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 12.918MB for 1048588-byte allocation 
01-01 16:55:22.855 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed <1K, 18% free 13199K/16007K, paused 2ms, total 2ms 
01-01 16:55:22.855 4495-4495/com.example.admin.pcremote D/dalvikvm: GC_FOR_ALLOC freed 0K, 18% free 13199K/16007K, paused 2ms, total 2ms 
01-01 16:55:22.865 4495-4495/com.example.admin.pcremote I/dalvikvm-heap: Grow heap (frag case) to 15.168MB for 2359308-byte allocation 
01-01 16:55:22.865 4495-4499/com.example.admin.pcremote D/dalvikvm: GC_CONCURRENT freed 0K, 16% free 15503K/18375K, paused 0ms+1ms, total 3ms 
01-01 16:55:22.895 4495-4495/com.example.admin.pcremote I/dalvikvm: Could not find method android.support.v7.widget.LinearLayoutCompat.drawableHotspotChanged, referenced from method android.support.design.internal.ForegroundLinearLayout.drawableHotspotChanged 
01-01 16:55:22.895 4495-4495/com.example.admin.pcremote W/dalvikvm: VFY: unable to resolve virtual method 16053: Landroid/support/v7/widget/LinearLayoutCompat;.drawableHotspotChanged (FF)V 
01-01 16:55:22.895 4495-4495/com.example.admin.pcremote D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000 

回答

0

最後審查與主要活動的所有其他佈局文件後,我們得到了我們的問題的解決方案

解決方案 C掛起content_main。XML德興視圖從AppTheme.NoActionBarAppTheme 和正常的方式表現其活性...