MainActivty不在牛轧糖和奥利奥上开始

时间:2018-09-23 04:58:53

标签: java android android-layout

在Android 9设备(天堂OS 16)上运行该应用程序时,它可以正常运行。但是,当我尝试在Nougat或Oreo等设备上打开它时,它只会显示空白的白色活动。 (注意:在Android 9(世系OS)中,我只得到了1或2秒的白色空白屏幕,但是在Nougat和Oreo中,它卡在了空白白色屏幕上。我尝试启动其他活动,如启动器活动和其他活动一样,但应将MainActivity类启动,以使其他活动正常工作。我不知道该错误是在布局设计中还是在Java类中(我认为该错误可能不在Java类中,因为该应用程序可在Android 9设备上完美运行!!)。在这里,我提供了xml布局和Java类。

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:id="@+id/ll_ads"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal" />
        <RelativeLayout
            android:id="@+id/track_info"
            android:background="#ff0000"
            android:visibility="gone"
            android:layout_width="fill_parent"
            android:layout_height="@dimen/track_info_layout_height"
            android:layout_above="@+id/ll_ads">
            <LinearLayout
                android:background="@color/bottom_control_background"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
                <com.makeramen.roundedimageview.RoundedImageView
                    android:layout_gravity="center_vertical"
                    android:id="@+id/artwork_min"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4.0dip"
                    android:src="@drawable/default_artwork"
                    android:scaleType="fitXY"
                    android:contentDescription="@string/album_artwork" />
                <RelativeLayout
                    android:padding="@dimen/content_padding"
                    android:layout_width="0.0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.0">
                    <TextView
                        android:textSize="16.0sp"
                        android:textStyle="bold"
                        android:textColor="#ffffff"
                        android:ellipsize="end"
                        android:id="@+id/song_title"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:singleLine="true"
                        android:layout_alignParentTop="true" />
                    <TextView
                        android:textSize="14.0sp"
                        android:textColor="#ffffff"
                        android:ellipsize="end"
                        android:id="@+id/song_artist"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4.0dip"
                        android:singleLine="true"
                        android:layout_below="@+id/song_title" />
                </RelativeLayout>
                <LinearLayout
                    android:id="@+id/quick_controls"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent">
                    <ImageButton
                        android:id="@+id/quick_prev"
                        android:background="?selectableItemBackgroundBorderless"
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:src="@drawable/btn_prev"
                        android:scaleType="center"
                        android:contentDescription="@string/prev" />
                    <ImageButton
                        android:id="@+id/quick_play_pause_toggle"
                        android:background="?selectableItemBackgroundBorderless"
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:src="@drawable/btn_play"
                        android:scaleType="center"
                        android:contentDescription="@string/play" />
                    <ImageButton
                        android:id="@+id/quick_next"
                        android:background="?selectableItemBackgroundBorderless"
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:src="@drawable/btn_next"
                        android:scaleType="center"
                        android:contentDescription="@string/next" />
                </LinearLayout>
            </LinearLayout>
            <com.musicplayer.players9.musicsamsung.free2018.widgets.ProgressBar
                android:id="@+id/progress_bar"
                android:padding="0.0dip"
                android:layout_width="fill_parent"
                android:layout_height="2.0dip"
                android:layout_alignParentTop="true"
                app:progressColor="?colorAccent" />
        </RelativeLayout>
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/track_info" />
    </RelativeLayout>
    <android.support.design.widget.NavigationView
        android:layout_gravity="start"
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        app:menu="@menu/navigation" />
</android.support.v4.widget.DrawerLayout>

Java类 Lint to Java Class

1 个答案:

答案 0 :(得分:1)

不可能...我不是在写它作为答案;我将在他阅读后将其删除。 但是,如果逐行接着进行相同的更改,它也会得到解决

  

停止对mainsctivity中的数千行进行编码

不是所有代码,逻辑和操作都在这里... !!

  

那么什么是mainActivity?

据我所知,仅100行代码

  

这100行代码应该做什么?

检查android版本,如果在棉花糖上方,请问下面的权限什么都不做。并在主线程上启动服务,或在其他线程上启动用于操作和任务的.. !!

解决方案:

  1. 通过创建导航项目的示例代码来创建新项目,该示例代码在创建新项目时已在android studio中准备就绪
  2. 忘记编码。不要编写单行代码,保持原样。
  3. 通过所有模拟器(例如5.0、6.0、7.0、8.0、9.0)进行检查
  4. 它将起作用,并且必须起作用.. !!
  5. 现在在mainactivity中只需获得权限即可。
  6. 无论执行什么操作,都需要在后台线程中执行。
  7. 是的,我知道您也会问我是否也要访问主用户界面...
  8. 请查看并执行此视频的示例代码...请不要避免观看...不要欺骗自己... Very simple demonstration of performing operations in android projects
  9. 再次完成,将您的代码从以前的应用程序移至新结构
  10. 这需要时间...,但这是正确的方法。

那。它。

  

我知道这不是答案...,我知道这也不应该是错误