Layout Design[UI Design]

R.layout.single_item

Create a new android project

Steps to follow:

Open the android Studio

Select File -> New -> Android Application Project.

The Android Application window is opened .Once opened fill the following details

1. Application name (Unique name )

2. Project Name

3. Package Name (Unique name )

Once completed the details do all the check mark like , class name and project location then press the next button bottom of the android application window

Then activity window opened name it whatever (As per java Standard).

AdapterSampleActivity[AdapterSampleActivity.class]

package com.androidfeeders.adaptersample;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class AdapterSampleActivity extends AppCompatActivity
{
ListView listView;
String[]stringArray;
ArrayAdapter stringArrayAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView=(ListView)findViewById(R.id.list_item);

    // getting from resources
    stringArray= getResources().getStringArray(R.array.list);

    //adapter settings
    stringArrayAdapter= new ArrayAdapter(this,
        android.R.layout.simple_list_item_1,
        stringArray);

        //set adapter
        listView.setAdapter(stringArrayAdapter);
        }
        }

Create a android application UI (User Interface) Screen

Right click the layout under the resource folder ,and select new -> Android xml file .

The new android xml file window is displayed

Select -> Layout Resource Type

Fill the following details

1.File Name

2. Root Element

3. Soruce set

4.Directory name

Layout Resource[activity_main.xml]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AdapterSampleActivity">

<ListView
android:id="@+id/list_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</LinearLayout>

Gradle Scripts~build.gradle[Module:app]

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.androidfeeders.adaptersample"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Gradle Scripts~build.gradle[Project:BaseAdapterSample]

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Resource[strings.xml]

<resources>
<string name="app_name">AdapterSample</string>

<string-array name="list">
<item name="string_name_one">Cupcake</item>
<item name="string_name_two">Cupcake</item>
<item name="string_name_three">Donut</item>
<item name="string_name_four">Eclair</item>
<item name="string_name_five">Froyo</item>
<item name="string_name_six">Gingerbread</item>
<item name="string_name_seven">Honeycomb</item>
<item name="string_name_eight">Ice Cream Sandwich</item>
<item name="string_name_nine">KitKat</item>
<item name="string_name_ten">Lollipop</item>
<item name="string_name_eleven">Marshmallow</item>
<item name="string_name_twelve">Nougat</item>
<item name="string_name_thirteen">Oreo</item>
</string-array>
</resources>

Menifest (Registering the Activity & Sevice & Receiver)

To Register the Activity

1.Double click the android manifest.xml under the application section in the current project package window

2. Then we need to edit the manifest in editor section of the current window .

manifests

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidfeeders.adaptersample">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".AdapterSampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Ramasamy

I started to learn android and Kotlin and iOS and Hybrid application and i cant code IOS very well. But i love more interesting to code and finding new developer minds who are join to me You're welcome to keep on using my website.Instead, you can join our FB page for developer comments and post there: https://www.facebook.com/ramasamy.m.779 Best wishes :) Ramasamy(Software Developer)

Android Development and IOS Development & React Native Application

See what's new in Android & IOS & Hybrid development … explore and learn in site

About Ramasamy

Kotlin and React native example too

Related Posts

3 Comments

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Ramasamy

5 min ago

Kotlin and React native example too

Reply

Leave a reply