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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With