Freelance Project Requests Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net

Android Studio error: expected resource of type layout
When you create an adapter for a ListView, the ListView is not recognized as a resource in the ArrayAdapter.

ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, , arrayList_Contacts);

In the Java code (Android Studio)

Error message:

Expected resource of type layout less...(ALT + T)
This inspection looks at Android API calls that have been annotated with various support annotations (such as RequiresPermission or UiThread) and flags any calls that are not using the API correctly as specified by the annotations.

Examples of errors flagged by this inspection:
  • Passing the wrong type of resource integer (such as R.string) to to API that expects a different type (such as R.dimen).
  • Forgetting to invoke the overridden method (via super) in methods that require it
  • Calling a method that requires a permission without having declared that permission in the manifest
  • Passing a resource color reference to a method which expects to RGB integer value.

...and many more.

The ListView is set in a Fragment.xml as base, which is dynamically loaded into a TabActivty.

The ListView is defined as a resource: android: id ="@+ id / listview_Contacts '

Android: layout_width ="match_parent"
Android: layout_height ="match_parent"
Tools: context ="layout.Contacts"


Android: layout_width ="wrap_content"
Android: layout_height ="wrap_content"
Android: id ="@+ id / listview_Contacts '
Android: layout_below ="@+ id / btnRead_Contacts"
Android: layout_alignParentLeft ="true"
Android: layout_alignParentStart ="true"
Android: choiceMode ="singleChoice"/>


You must specify not the ListView as a paramter in ArrayAdapter, but a Resource file with line items.
To do this, it is necessary in the directory / layout to create a new layout resource file

In the dialog: new resource file is there in the file name to an appropriate name for the file elements.
The contact_items file is called. It then creates a file contact_items.xml.
In directory name: to choose / layout as the directory where the xml file is saved.

The new resource file will appear in the display as an activity, is but a resource file

The text view displays the new resource file in xml according to the scheme:
XML header and a LinearLayout element.

<?XML version ="1.0"encoding ="utf-8"?>
Android: orientation ="vertical"
Android: layout_width ="match_parent"
Android: layout_height ="match_parent">


It is necessary the LinearLayout element in a TextView change, so that this list can be shown in a ListView.

You have the only minor item in a TextView in the resourcefile rename.
As a result it can be represented in a ListView as a line item.

<?XML version ="1.0"encoding ="utf-8"?>
Android: orientation ="vertical"
Android: layout_width ="match_parent"
Android: layout_height ="match_parent">


If the xml as a resource file in / layout is gespeichere, then it is found also with IntellJ to the selection in code.
However, under R.Layout and not under

Proper java code
The resource is determined from R.Layout and not about

//< show results >
//txtResult_Contacts.setText(sNodes); //*as text

ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.layout.contact_items, arrayList_Contacts);
//</ show results >

App settings as app preferences save and read
Add Android settings to an app project
Android code: Lookup a contact by the phone number
Android code: Add contact person, email, telephone with batch operations
Android Studio: Add contact using Android intent
Android code: Automatically dial a phone number
Android app code: Start stop Wi-Fi with Java code
Android app code: App to turn on WiFi by Intent
Android: Macro Coding with Intent and StartActivity
Android code: Android read contacts and store it in a ListView


Contact for Jobs, Project Requests: