4

I cant seem to find what is wrong with my program with this error please

My code is long for me to post all my R. got red highlighted after i included this

LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.toast_layout,
                    (ViewGroup) findViewById(R.id.toast_layout_root));

            TextView text = (TextView) layout.findViewById(R.id.text);
            text.setText("Please select a Level!");
            text.setTextColor(Color.BLUE);
            text.setTextSize(15);

            Toast toast = new Toast(getApplicationContext());
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.setDuration(Toast.LENGTH_SHORT);
            // toast.getView().setBackgroundColor(Color.BLUE);
            toast.setView(layout);
            toast.show();

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toast_layout_root"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="8dp"
    android:background="#DAAA"
    >
    <ImageView android:src="@drawable/droid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="8dp"
        />

    <TextView android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FFF"
        />
</LinearLayout>

help

Madona wambua
  • 1,408
  • 1
  • 21
  • 37

4 Answers4

0

add

multiDexEnabled true 

on your grandle file

check this

Community
  • 1
  • 1
souttab
  • 696
  • 6
  • 12
0

Find and delete jpg variants of your drawables (android studio can find it, so can you). Delete images.jpg, tryagain.jpg, etc.

Anton Malyshev
  • 8,686
  • 2
  • 27
  • 45
0

Things to check

  1. Check if you image.jpg and image.png both in drawable folders.

if this is not case

  1. Perform Build > Clean Project

if still not resolved issue

  1. File > Invalidate Cache And Restart
Kirtan
  • 1,782
  • 1
  • 13
  • 35
0

Check your number of methods!

In my case, I included a big library (google play services) to my project and then the 65k method limit got exceeded.

Replacing it with the much smaller maps library fixed this problem.

Lukas Lechner
  • 7,881
  • 7
  • 40
  • 53