Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Layout not detecting in mainActivity class?

I am a beginner at android.

I am using Android Studio 1.0. I am trying to make a custom layout for listView. I created custom layout files in the res/layout named row_layout. xml for layout is this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/cl_textView"
    android:textSize="30sp"
    android:textStyle="bold"
    android:padding="15dp"/>
</LinearLayout>

Code to implement that custom layout in the MainActivity class is:

  ListAdapter theAdapter = new ArrayAdapter<String>(this, android.R.layout.row_layout,toDoList);

But activity class doesn't detect this custom layout and shows the error below while building.

enter image description here

like image 470
Prajeet Shrestha Avatar asked Mar 18 '23 12:03

Prajeet Shrestha


1 Answers

You have to replace the android.R. with R. because R.* provides your application resources instead, android.R.* provides resources that ship with the Android SDK. ( R.* is actually shortcut for your.package.R.* )

Hope it helps.

like image 111
Fouad Wahabi Avatar answered Mar 20 '23 00:03

Fouad Wahabi