Мое приложение работало нормально, пока я не добавил новую кнопку, которая действует как ссылка. Приложение работает в эмуляторе Pixel_2_API_29 с разрешением 1080x1920, но оно не работает на моем мобильном HUAWEI AUM_L29.
Мой xml файл для активности:
<Button
android:id="@+id/button1"
android:background="@android:color/secondary_text_dark"
android:layout_width="wrap_content"
android:cursorVisible="true"
android:autoLink="web"
android:onClick="aj"
android:clickable="true"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Spotlight"
android:textStyle="bold"
android:layout_marginTop="65dp"
android:layout_marginStart="-75dp"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="65dp"
android:layout_marginTop="65dp"
android:background="@android:color/secondary_text_dark"
android:text="Biography"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageview25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="470dp"
android:src="@drawable/logo"
android:scaleType="fitCenter"
/>
<ImageView
android:id="@+id/imageview22"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="280dp"
android:layout_marginTop="112dp"
android:src="@drawable/i00"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/imageview24"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="200dp"
android:layout_marginTop="112dp"
android:src="@drawable/i00"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/imageview23"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="120dp"
android:layout_marginTop="112dp"
android:src="@drawable/i00"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/textview"
android:layout_width="396dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textview1"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="Champion counters"
android:textColor="@android:color/black"
android:textSize="25dp" />
<TextView
android:id="@+id/textview3"
android:layout_width="396dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textview1"
android:layout_marginTop="250dp"
android:gravity="center"
android:text="Champion spotlight and biography"
android:textColor="@android:color/black"
android:textSize="25dp" />
<ImageView
android:id="@+id/imageview21"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="40dp"
android:layout_marginTop="112dp"
android:src="@drawable/i00"
android:scaleType="fitCenter"/>
Моя активность:
TextView mtitle;
ImageView imageView, imageView2,imageView3,imageView4,imageView5,imageView6,
imageView7,imageView8;
private TabLayout tabLayout;
private ViewPager viewPager;
private TabItem tab1,tab2,tab3;
public PagerAdapter pagerAdapter;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_another);
mtitle = findViewById(R.id.titleTv);
imageView = findViewById(R.id.imageview);
imageView2 = findViewById(R.id.imageview2);
imageView3 = findViewById(R.id.imageview3);
imageView4 = findViewById(R.id.imageview4);
imageView5 = findViewById(R.id.imageview5);
imageView6 = findViewById(R.id.imageview6);
imageView7 = findViewById(R.id.imageview7);
imageView8 = findViewById(R.id.imageview8);
Intent intent = getIntent();
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
tab1 = (TabItem) findViewById(R.id.tab1);
tab2 = (TabItem) findViewById(R.id.tab2);
tab3 = (TabItem) findViewById(R.id.tab3);
viewPager = findViewById(R.id.viewPager);
pagerAdapter = new PageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(pagerAdapter);
tabLayout.setOnTabSelectedListener(new TabLayout.BaseOnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
if(tab.getPosition() == 0){
pagerAdapter.notifyDataSetChanged();
}
else if(tab.getPosition() == 1){
pagerAdapter.notifyDataSetChanged();
}
else if(tab.getPosition() == 2){
pagerAdapter.notifyDataSetChanged();
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
viewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
Exception exception = new Exception();
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
exception.printStackTrace(printWriter);
printWriter.flush();
String stackTrace = writer.toString();
}
public void aj(View view){
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://leagueoflegends.fandom.com/wiki/Ahri"));
startActivity(i);
}
Logcat:
Process: com.josipjuhasz.projekt, PID: 22666
android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class Button
Caused by: android.content.res.Resources$NotFoundException: Drawable android:color/secondary_text_dark with resource ID #0x1060005
Caused by: android.content.res.Resources$NotFoundException: File res/color/secondary_text_dark.xml from drawable resource ID #0x1060005
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:1097)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:908)
at android.content.res.Resources.loadDrawable(Resources.java:1036)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:1005)
at android.content.res.TypedArray.getDrawable(TypedArray.java:980)
at android.view.View.<init>(View.java:4746)
at android.widget.TextView.<init>(TextView.java:878)
at android.widget.Button.<init>(Button.java:172)
at android.widget.Button.<init>(Button.java:147)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:71)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:67)
at androidx.appcompat.app.AppCompatViewInflater.createButton(AppCompatViewInflater.java:187)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:110)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:783)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.josipjuhasz.projekt.tab3.onCreateView(tab3.java:27)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1539)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:823)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:702)
at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
E/AndroidRuntime: at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1539)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:823)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:702)
at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1539)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:823)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:702)
at android.view.View.measure(View.java:22216)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6671)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:831)
at android.view.View.measure(View.java:22216)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2589)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1631)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1885)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7266)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:981)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:721)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:189)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:122)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:145)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1254)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:1084)
... 79 more
Я думаю, что проблема где-то в методе onClick, но я не знаю где. Как я уже сказал, я новичок в Android Studio, и меня это раздражает.
Заранее спасибо!