<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Android_Studio%3A_Cara_Membuat_Android_Apps_3</id>
	<title>Android Studio: Cara Membuat Android Apps 3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Android_Studio%3A_Cara_Membuat_Android_Apps_3"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_3&amp;action=history"/>
	<updated>2026-04-20T11:18:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_3&amp;diff=42692&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: In this part of the tutorial I’ll cover Android ListViews, ArrayAdapters, Custom Array Adapters, ListAdapter, LayoutInflator, ImageView, and a great deal about terminology that confuses ...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_3&amp;diff=42692&amp;oldid=prev"/>
		<updated>2015-03-18T03:17:07Z</updated>

		<summary type="html">&lt;p&gt;New page: In this part of the tutorial I’ll cover Android ListViews, ArrayAdapters, Custom Array Adapters, ListAdapter, LayoutInflator, ImageView, and a great deal about terminology that confuses ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In this part of the tutorial I’ll cover Android ListViews, ArrayAdapters, Custom Array Adapters, ListAdapter, LayoutInflator, ImageView, and a great deal about terminology that confuses people.&lt;br /&gt;
&lt;br /&gt;
To learn how Android Studio works look here at my Android Studio tutorial. If you missed the first part of this tutorial it is here How to Make Android Apps. All of the code used follows the video below.&lt;br /&gt;
&lt;br /&gt;
If you like videos like this, it helps me if you share it on Google Plus with a click here&lt;br /&gt;
&lt;br /&gt;
Code From the Video&lt;br /&gt;
&lt;br /&gt;
The first 2 files are for the first easy ListView example. The rest of the files are for the last 2 examples.&lt;br /&gt;
&lt;br /&gt;
Main_Activity.java&lt;br /&gt;
&lt;br /&gt;
package com.newthinktank.listviewexample.app;&lt;br /&gt;
&lt;br /&gt;
import android.app.Activity;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.support.v7.app.ActionBarActivity;&lt;br /&gt;
import android.view.Menu;&lt;br /&gt;
import android.view.MenuItem;&lt;br /&gt;
import android.view.View;&lt;br /&gt;
import android.widget.AdapterView;&lt;br /&gt;
import android.widget.ArrayAdapter;&lt;br /&gt;
import android.widget.ListAdapter;&lt;br /&gt;
import android.widget.ListView;&lt;br /&gt;
import android.widget.Toast;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class MainActivity extends ActionBarActivity {&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_main);&lt;br /&gt;
&lt;br /&gt;
        // Simple array with a list of my favorite TV shows&lt;br /&gt;
        String[] favoriteTVShows = {&amp;quot;Pushing Daisies&amp;quot;, &amp;quot;Better Off Ted&amp;quot;,&lt;br /&gt;
        &amp;quot;Twin Peaks&amp;quot;, &amp;quot;Freaks and Geeks&amp;quot;, &amp;quot;Orphan Black&amp;quot;, &amp;quot;Walking Dead&amp;quot;,&lt;br /&gt;
        &amp;quot;Breaking Bad&amp;quot;, &amp;quot;The 400&amp;quot;, &amp;quot;Alphas&amp;quot;, &amp;quot;Life on Mars&amp;quot;};&lt;br /&gt;
&lt;br /&gt;
        // The ListAdapter acts as a bridge between the data and each ListItem&lt;br /&gt;
        // You fill the ListView with a ListAdapter. You pass it a context represented by&lt;br /&gt;
        // this. A Context provides access to resources you need.&lt;br /&gt;
        // android.R.layout.simple_list_item_1 is one of the resources needed.&lt;br /&gt;
        // It is a predefined layout provided by Android that stands in as a default&lt;br /&gt;
&lt;br /&gt;
        ListAdapter theAdapter = new ArrayAdapter&amp;lt;String&amp;gt;(this, android.R.layout.simple_list_item_1,&lt;br /&gt;
                favoriteTVShows);&lt;br /&gt;
&lt;br /&gt;
        // ListViews display data in a scrollable list&lt;br /&gt;
        ListView theListView = (ListView) findViewById(R.id.theListView);&lt;br /&gt;
&lt;br /&gt;
        // Tells the ListView what data to use&lt;br /&gt;
        theListView.setAdapter(theAdapter);&lt;br /&gt;
&lt;br /&gt;
        theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onItemClick(AdapterView&amp;lt;?&amp;gt; adapterView, View view, int i, long l) {&lt;br /&gt;
&lt;br /&gt;
                String tvShowPicked = &amp;quot;You selected &amp;quot; +&lt;br /&gt;
                        String.valueOf(adapterView.getItemAtPosition(i));&lt;br /&gt;
&lt;br /&gt;
                Toast.makeText(MainActivity.this, tvShowPicked, Toast.LENGTH_SHORT).show();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onCreateOptionsMenu(Menu menu) {&lt;br /&gt;
        // Inflate the menu; this adds items to the action bar if it is present.&lt;br /&gt;
        getMenuInflater().inflate(R.menu.main, menu);&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onOptionsItemSelected(MenuItem item) {&lt;br /&gt;
        // Handle action bar item clicks here. The action bar will&lt;br /&gt;
        // automatically handle clicks on the Home/Up button, so long&lt;br /&gt;
        // as you specify a parent activity in AndroidManifest.xml.&lt;br /&gt;
        int id = item.getItemId();&lt;br /&gt;
        if (id == R.id.action_settings) {&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        return super.onOptionsItemSelected(item);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
activity_main.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;&lt;br /&gt;
    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:layout_height=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:paddingLeft=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;
    android:paddingRight=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;
    android:paddingTop=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;
    android:paddingBottom=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;
    android:orientation=&amp;quot;vertical&amp;quot;&lt;br /&gt;
    tools:context=&amp;quot;com.newthinktank.listviewexample.app.MainActivity&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;ListView&lt;br /&gt;
        android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
        android:layout_height=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
        android:id=&amp;quot;@+id/theListView&amp;quot;&amp;gt;&amp;lt;/ListView&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
activity_main.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;&lt;br /&gt;
    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:layout_height=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:paddingLeft=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;
    android:paddingRight=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;
    android:paddingTop=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;
    android:paddingBottom=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;
    android:orientation=&amp;quot;vertical&amp;quot;&lt;br /&gt;
    tools:context=&amp;quot;com.newthinktank.listviewexample2.app.MainActivity&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;ListView&lt;br /&gt;
        android:id=&amp;quot;@+id/listView1&amp;quot;&lt;br /&gt;
        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;
        android:layout_height=&amp;quot;wrap_content&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MainActivity.java&lt;br /&gt;
&lt;br /&gt;
package com.newthinktank.listviewexample2.app;&lt;br /&gt;
&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.support.v7.app.ActionBarActivity;&lt;br /&gt;
import android.view.Menu;&lt;br /&gt;
import android.view.MenuItem;&lt;br /&gt;
import android.widget.ArrayAdapter;&lt;br /&gt;
import android.widget.ListAdapter;&lt;br /&gt;
import android.widget.ListView;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class MainActivity extends ActionBarActivity {&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_main);&lt;br /&gt;
&lt;br /&gt;
        // Simple array with a list of my favorite TV shows&lt;br /&gt;
        String[] favoriteTVShows = {&amp;quot;Pushing Daisies&amp;quot;, &amp;quot;Better Off Ted&amp;quot;,&lt;br /&gt;
                &amp;quot;Twin Peaks&amp;quot;, &amp;quot;Freaks and Geeks&amp;quot;, &amp;quot;Orphan Black&amp;quot;, &amp;quot;Walking Dead&amp;quot;,&lt;br /&gt;
                &amp;quot;Breaking Bad&amp;quot;, &amp;quot;The 400&amp;quot;, &amp;quot;Alphas&amp;quot;, &amp;quot;Life on Mars&amp;quot;};&lt;br /&gt;
&lt;br /&gt;
        // A View is the generic term and class for every widget you put on your screen.&lt;br /&gt;
        // Views occupy a rectangular area and are responsible for handling events&lt;br /&gt;
        // and drawing the widget.&lt;br /&gt;
&lt;br /&gt;
        // The ListAdapter acts as a bridge between the data and each ListItem&lt;br /&gt;
        // You fill the ListView with a ListAdapter. You pass it a context represented by&lt;br /&gt;
        // this.&lt;br /&gt;
&lt;br /&gt;
        // A Context provides access to resources you need. It provides the current Context, or&lt;br /&gt;
        // facts about the app and the events that have occurred with in it.&lt;br /&gt;
        // android.R.layout.simple_list_item_1 is one of the resources needed.&lt;br /&gt;
        // It is a predefined layout provided by Android that stands in as a default&lt;br /&gt;
&lt;br /&gt;
         ListAdapter theAdapter = new ArrayAdapter&amp;lt;String&amp;gt;(this, R.layout.row_layout,&lt;br /&gt;
            R.id.textView1, favoriteTVShows);&lt;br /&gt;
&lt;br /&gt;
        // We point the ListAdapter to our custom adapter&lt;br /&gt;
        // ListAdapter theAdapter = new MyAdapter(this, favoriteTVShows);&lt;br /&gt;
&lt;br /&gt;
        // Get the ListView so we can work with it&lt;br /&gt;
        ListView theListView = (ListView) findViewById(R.id.listView1);&lt;br /&gt;
&lt;br /&gt;
        // Connect the ListView with the Adapter that acts as a bridge between it and the array&lt;br /&gt;
        theListView.setAdapter(theAdapter);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onCreateOptionsMenu(Menu menu) {&lt;br /&gt;
        // Inflate the menu; this adds items to the action bar if it is present.&lt;br /&gt;
        getMenuInflater().inflate(R.menu.main, menu);&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onOptionsItemSelected(MenuItem item) {&lt;br /&gt;
        // Handle action bar item clicks here. The action bar will&lt;br /&gt;
        // automatically handle clicks on the Home/Up button, so long&lt;br /&gt;
        // as you specify a parent activity in AndroidManifest.xml.&lt;br /&gt;
        int id = item.getItemId();&lt;br /&gt;
        if (id == R.id.action_settings) {&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        return super.onOptionsItemSelected(item);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
MyAdapter.java&lt;br /&gt;
&lt;br /&gt;
package com.newthinktank.listviewexample2.app;&lt;br /&gt;
&lt;br /&gt;
import android.content.Context;&lt;br /&gt;
import android.view.LayoutInflater;&lt;br /&gt;
import android.view.View;&lt;br /&gt;
import android.view.ViewGroup;&lt;br /&gt;
import android.widget.ArrayAdapter;&lt;br /&gt;
import android.widget.ImageView;&lt;br /&gt;
import android.widget.TextView;&lt;br /&gt;
&lt;br /&gt;
// We can create custom adapters&lt;br /&gt;
class MyAdapter extends ArrayAdapter&amp;lt;String&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    public MyAdapter(Context context, String[] values){&lt;br /&gt;
&lt;br /&gt;
        super(context, R.layout.row_layout_2, values);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Override getView which is responsible for creating the rows for our list&lt;br /&gt;
    // position represents the index we are in for the array.&lt;br /&gt;
&lt;br /&gt;
    // convertView is a reference to the previous view that is available for reuse. As&lt;br /&gt;
    // the user scrolls the information is populated as needed to conserve memory.&lt;br /&gt;
&lt;br /&gt;
    // A ViewGroup are invisible containers that hold a bunch of views and&lt;br /&gt;
    // define their layout properties.&lt;br /&gt;
    @Override&lt;br /&gt;
    public View getView(int position, View convertView, ViewGroup parent) {&lt;br /&gt;
&lt;br /&gt;
        // The LayoutInflator puts a layout into the right View&lt;br /&gt;
        LayoutInflater theInflater = LayoutInflater.from(getContext());&lt;br /&gt;
&lt;br /&gt;
        // inflate takes the resource to load, the parent that the resource may be&lt;br /&gt;
        // loaded into and true or false if we are loading into a parent view.&lt;br /&gt;
        View theView = theInflater.inflate(R.layout.row_layout_2, parent, false);&lt;br /&gt;
&lt;br /&gt;
        // We retrieve the text from the array&lt;br /&gt;
        String tvShow = getItem(position);&lt;br /&gt;
&lt;br /&gt;
        // Get the TextView we want to edit&lt;br /&gt;
        TextView theTextView = (TextView) theView.findViewById(R.id.textView1);&lt;br /&gt;
&lt;br /&gt;
        // Put the next TV Show into the TextView&lt;br /&gt;
        theTextView.setText(tvShow);&lt;br /&gt;
&lt;br /&gt;
        // Get the ImageView in the layout&lt;br /&gt;
        ImageView theImageView = (ImageView) theView.findViewById(R.id.imageView1);&lt;br /&gt;
&lt;br /&gt;
        // We can set a ImageView like this&lt;br /&gt;
        theImageView.setImageResource(R.drawable.dot);&lt;br /&gt;
&lt;br /&gt;
        return theView;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
row_layout.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;&lt;br /&gt;
    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:layout_height=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:orientation=&amp;quot;vertical&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Used to define a custom ListView row --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;TextView&lt;br /&gt;
        android:id=&amp;quot;@+id/textView1&amp;quot;&lt;br /&gt;
        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;
        android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;
        android:textSize=&amp;quot;30sp&amp;quot;&lt;br /&gt;
        android:textStyle=&amp;quot;bold&amp;quot;&lt;br /&gt;
        android:padding=&amp;quot;15dp&amp;quot;&lt;br /&gt;
        /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
row_layout_2.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;&lt;br /&gt;
    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:layout_height=&amp;quot;match_parent&amp;quot;&lt;br /&gt;
    android:orientation=&amp;quot;horizontal&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Image for each ListItem row&lt;br /&gt;
    We can refer to images in our drawable folder with&lt;br /&gt;
    @drawable/dot for the image named dot.png --&amp;gt;&lt;br /&gt;
    &amp;lt;ImageView&lt;br /&gt;
        android:id=&amp;quot;@+id/imageView1&amp;quot;&lt;br /&gt;
        android:layout_width=&amp;quot;25dp&amp;quot;&lt;br /&gt;
        android:layout_height=&amp;quot;25dp&amp;quot;&lt;br /&gt;
        android:layout_marginLeft=&amp;quot;10dp&amp;quot;&lt;br /&gt;
        android:layout_marginTop=&amp;quot;25dp&amp;quot;&lt;br /&gt;
        android:src=&amp;quot;@drawable/dot&amp;quot;/&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;!-- Used to define a custom ListView row --&amp;gt;&lt;br /&gt;
    &amp;lt;TextView&lt;br /&gt;
        android:id=&amp;quot;@+id/textView1&amp;quot;&lt;br /&gt;
        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;
        android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;
        android:textSize=&amp;quot;30sp&amp;quot;&lt;br /&gt;
        android:textStyle=&amp;quot;bold&amp;quot;&lt;br /&gt;
        android:padding=&amp;quot;15dp&amp;quot;&lt;br /&gt;
        /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Presentation Slides&lt;br /&gt;
&lt;br /&gt;
Click the images below to view them full screen&lt;br /&gt;
&lt;br /&gt;
Android ListView&lt;br /&gt;
&lt;br /&gt;
Android ListView&lt;br /&gt;
&lt;br /&gt;
Android ListView 3&lt;br /&gt;
&lt;br /&gt;
Android ListView 4&lt;br /&gt;
- See more at: http://www.newthinktank.com/2014/06/make-android-apps-3/#sthash.e4sAoTo7.dpuf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* http://www.newthinktank.com/2014/06/make-android-apps-3/&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>