결과화면

package com.example.containerdemo;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ListViewDemo2 extends ListActivity {
 String[] items = null;
 private TextView selected;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.listviewdemo_2);

  selected = (TextView)findViewById(R.id.selected);

  items = getResources().getStringArray(R.array.phone);


  setListAdapter(new ArrayAdapter<String>
  (this, android.R.layout.simple_list_item_1, items));

 

//  setListAdapter(new ArrayAdapter<String>
//  (this, android.R.layout.simple_list_item_single_choice, items));
//  
//  setListAdapter(new ArrayAdapter<String>
//  (this, android.R.layout.simple_list_item_multiple_choice, items));
 }


 public void onListItemClick(ListView parent, View v, int position, long id){
  selected.setText(items[position] + " : " + position + ":" + id);
 }
}

 

 

 

 

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="선택항목 : " />

        <TextView
            android:id="@+id/selected"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="선택한 것이 없습니다." />
    </LinearLayout>

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

</LinearLayout>

 

 

 

 

 

//values폴더에 arrays.xml 생성

 

 

 <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="phone">
        <item>Iphone4</item>
        <item>Iphone4s</item>
        <item>Iphone5</item>
        <item>Iphone5s</item>
        <item>Iphone5c</item>
        <item>galaxy S</item>
        <item>galaxy S2</item>
        <item>galaxy S2 HD</item>
        <item>galaxy S3 3G</item>
        <item>galaxy S3 LTE</item>
        <item>galaxy S4</item>
        <item>galaxy S4 LTE-A</item>
        <item>vega R3</item>
        <item>vega IRON</item>
        <item>vega LTE-A</item>
        <item>optimus G</item>
        <item>optimus G PRO</item>
        <item>optimus GK</item>
        <item>G2</item>
    </string-array>
</resources>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ListView Demo5  (0) 2013.08.14
ListView Demo3 - 리스트 추가, 삭제  (0) 2013.08.14
ListView Demo1  (0) 2013.08.14
HScrollView Demo  (0) 2013.08.14
SeekBar Demo  (0) 2013.08.13

결과화면

 

 package com.example.containerdemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ListViewDemo1 extends Activity {
 String[] items = null;
 private TextView selected;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.listviewdemo_1);
  
  selected = (TextView)findViewById(R.id.selected);
  ListView listview = (ListView)findViewById(R.id.list);
  
  items = getResources().getStringArray(R.array.phone);
  listview.setAdapter(new ArrayAdapter<String>
  (this, android.R.layout.simple_list_item_1, items));
  
  listview.setOnItemClickListener(new AdapterView.OnItemClickListener(){
   public void onItemClick(AdapterView<?> parent, View v, int position, long id){
    selected.setText(items[position] + " : " + position + ":" + id);
   }
  });
 }
}

 

 

 

 

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="선택항목 : " />

        <TextView
            android:id="@+id/selected"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="선택한 것이 없습니다." />
    </LinearLayout>

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

</LinearLayout>

 

 

 

 

//values폴더에 arrays.xml 생성

 

 

 <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="phone">
        <item>Iphone4</item>
        <item>Iphone4s</item>
        <item>Iphone5</item>
        <item>Iphone5s</item>
        <item>Iphone5c</item>
        <item>galaxy S</item>
        <item>galaxy S2</item>
        <item>galaxy S2 HD</item>
        <item>galaxy S3 3G</item>
        <item>galaxy S3 LTE</item>
        <item>galaxy S4</item>
        <item>galaxy S4 LTE-A</item>
        <item>vega R3</item>
        <item>vega IRON</item>
        <item>vega LTE-A</item>
        <item>optimus G</item>
        <item>optimus G PRO</item>
        <item>optimus GK</item>
        <item>G2</item>
    </string-array>
</resources>

 

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ListView Demo3 - 리스트 추가, 삭제  (0) 2013.08.14
ListView Demo2 - extends ListActivity 이용...  (0) 2013.08.14
HScrollView Demo  (0) 2013.08.14
SeekBar Demo  (0) 2013.08.13
ProgressBar Demo3  (0) 2013.08.13

 결과화면

 

 

 package com.example.containerdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class HScrollViewDemo extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.hscorllview_demo);
 }
}

 <HorizontalScrollView 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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="200dip"
            android:layout_height="match_parent"
            android:background="#0000ff"
            android:gravity="center"
            android:text="@string/hello_world" />

        <TextView
            android:layout_width="300dip"
            android:layout_height="match_parent"
            android:background="#00ff00"
            android:gravity="center"
            android:text="@string/hello_world" />

        <TextView
            android:layout_width="400dip"
            android:layout_height="match_parent"
            android:background="#ff0000"
            android:gravity="center"
            android:text="@string/hello_world" />
    </LinearLayout>

</HorizontalScrollView>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ListView Demo2 - extends ListActivity 이용...  (0) 2013.08.14
ListView Demo1  (0) 2013.08.14
SeekBar Demo  (0) 2013.08.13
ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13

 결과화면

 

package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

public class SeekBarDemo extends Activity implements SeekBar.OnSeekBarChangeListener{
 SeekBar mSeekBar;
 TextView mProgressText;
 TextView mTrackingText;
 
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.seekbar_demo);
  
  mSeekBar = (SeekBar)findViewById(R.id.seek);
  mSeekBar.setOnSeekBarChangeListener(this);
  mProgressText = (TextView)findViewById(R.id.progress);
  mTrackingText = (TextView)findViewById(R.id.tracking);
 }
 
 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch){
  mProgressText.setText(progress + " " + getString(R.string.seekbar_from_touch) + "=" + fromTouch);
 }
 
 public void onStartTrackingTouch(SeekBar seekBar){
  mTrackingText.setText(getString(R.string.seekbar_tracking_on));
 }
 
 public void onStopTrackingTouch(SeekBar seekBar){
  mTrackingText.setText(getString(R.string.seekbar_tracking_off));
 }

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <SeekBar
        android:id="@+id/seek"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="50"
        android:secondaryProgress="75" />

    <TextView
        android:id="@+id/progress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/tracking"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

//String.xml에 코드 추가~!~!

 

 <string name="seekbar_tracking_on">Tracking on</string>
    <string name="seekbar_tracking_off">Tracking off</string>
    <string name="seekbar_from_touch">from touch</string>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ListView Demo1  (0) 2013.08.14
HScrollView Demo  (0) 2013.08.14
ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
ProgressBar Demo1  (0) 2013.08.13

 결과화면

 

 

package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class ProgressBarDemo3 extends Activity {
 private boolean mToggle = false;
 
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.progress_3);
  setProgressBarIndeterminateVisibility(mToggle);
  
  Button button = (Button)findViewById(R.id.toggle);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    mToggle = !mToggle;
    setProgressBarIndeterminateVisibility(mToggle);
   }
  });
 }
}

 

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button android:id="@+id/toggle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/progressbar_4_toggle" />

</LinearLayout>

//String.xml에 다음 코드 추가~~

 

 <string name="progressbar_4_toggle">Toggle Indeterminate</string>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

HScrollView Demo  (0) 2013.08.14
SeekBar Demo  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
ProgressBar Demo1  (0) 2013.08.13
Image Demo  (0) 2013.08.13

 결과화면

 

 package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.*;

public class ProgressBarDemo2 extends Activity {
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  requestWindowFeature(Window.FEATURE_PROGRESS);
  setProgressBarVisibility(true); //위에 requestWindowFeature 를 true로 지정한거임..
  
  setContentView(R.layout.progress_2);

 }
}

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ProgressBar android:id="@+android:id/progress_large"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <ProgressBar android:id="@+android:id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <ProgressBar android:id="@+android:id/progress_small"
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <ProgressBar android:id="@+android:id/progress_small_title"
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

SeekBar Demo  (0) 2013.08.13
ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo1  (0) 2013.08.13
Image Demo  (0) 2013.08.13
AutoText Demo 자동완성 텍스트뷰  (0) 2013.08.13

 결과화면

 

 package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.*;

public class ProgressBarDemo1 extends Activity {
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  //윈도우에 진행 상태바 설정.
  requestWindowFeature(Window.FEATURE_PROGRESS);
  setProgressBarVisibility(true); //위에 requestWindowFeature 를 true로 지정한거임..
  
  setContentView(R.layout.progress_1);
  
  final ProgressBar progressHorizontal =
    (ProgressBar)findViewById(R.id.progress_horizontal);
  
  setProgress(progressHorizontal.getProgress() * 100);
  setSecondaryProgress(progressHorizontal.getSecondaryProgress() * 100);
  
  Button button = (Button)findViewById(R.id.increase);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementProgressBy(1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.decrease);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementProgressBy(-1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.increase_secondary);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementSecondaryProgressBy(1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
  
  button = (Button)findViewById(R.id.decrease_secondary);
  button.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v){
    progressHorizontal.incrementSecondaryProgressBy(-1);
    //Title progress is in range 0..10000
    setProgress(100 * progressHorizontal.getProgress());
   }
  });
 }
}

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ProgressBar android:id="@+id/progress_horizontal"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="200dip"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="50"
        android:secondaryProgress="75" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/progressbar_1_default_progress" />       

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button android:id="@+id/decrease"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_minus" />

        <Button android:id="@+id/increase"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_plus" />

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/progressbar_1_secondary_progress" />       

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button android:id="@+id/decrease_secondary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_minus" />

        <Button android:id="@+id/increase_secondary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/progressbar_1_plus" />

    </LinearLayout>

</LinearLayout>

//String.xml에 다음 코드 추가~~

 

 <string name="progressbar_1_plus">+</string>
    <string name="progressbar_1_minus">-</string>
    <string name="progressbar_1_default_progress">Default progress:</string>
    <string name="progressbar_1_secondary_progress">Secondary progress:</string>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
Image Demo  (0) 2013.08.13
AutoText Demo 자동완성 텍스트뷰  (0) 2013.08.13
Spinner Demo  (0) 2013.08.13

결과화면

 

 

 package com.example.demo;

import android.app.Activity;
import android.os.Bundle;

public class ImageDemo extends Activity {
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.image_demo);
 }
}

 <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
   
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
       
        <!-- The following four examples use a large image -->
        <!-- 1. Non-scaled view, for reference -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_large_normal"/>
        <ImageView
            android:src="@drawable/sample_1"
            android:adjustViewBounds="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
           
        <!-- 2. Limit to at most 50x50 -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_large_at_most"/>
        <ImageView
            android:src="@drawable/sample_1"
            android:adjustViewBounds="true"
            android:maxWidth="50dip"
            android:maxHeight="50dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

       <!-- 3. Limit to at most 70x70, with 10 pixels of padding all around -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_large_at_most_padded"/>
       <ImageView
            android:src="@drawable/sample_1"
            android:background="#66FFFFFF"
            android:adjustViewBounds="true"
            android:maxWidth="70dip"
            android:maxHeight="70dip"
            android:padding="10dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
           
        <!-- 4. Limit to exactly 70x70, with 10 pixels of padding all around -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_large_exactly_padded"/>
        <ImageView
            android:src="@drawable/sample_1"
            android:background="#66FFFFFF"
            android:scaleType="centerInside"
            android:padding="10dip"
            android:layout_width="70dip"
            android:layout_height="70dip" />

        <!-- Repeating the previous four examples with small image -->
        <!-- 1. Non-scaled view, for reference -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_small_normal"/>
        <ImageView
            android:src="@drawable/stat_happy"
            android:background="#FFFFFFFF"
            android:adjustViewBounds="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
           
        <!-- 2. Limit to at most 50x50 -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_small_at_most"/>
        <ImageView
            android:src="@drawable/stat_happy"
            android:background="#FFFFFFFF"
            android:adjustViewBounds="true"
            android:maxWidth="50dip"
            android:maxHeight="50dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

       <!-- 3. Limit to at most 70x70, with 10 pixels of padding all around -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_small_at_most_padded"/>
        <ImageView
            android:src="@drawable/stat_happy"
            android:background="#FFFFFFFF"
            android:adjustViewBounds="true"
            android:maxWidth="70dip"
            android:maxHeight="70dip"
            android:padding="10dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
           
        <!-- 4. Limit to exactly 70x70, with 10 pixels of padding all around -->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/image_view_small_exactly_padded"/>
        <ImageView
            android:src="@drawable/stat_happy"
            android:background="#FFFFFFFF"
            android:scaleType="centerInside"
            android:padding="10dip"
            android:layout_width="70dip"
            android:layout_height="70dip" />

 
    </LinearLayout>
</ScrollView>

 

아차차!!! String.xml에 다음 코드 추가

 

<string name="image_view_large_normal">Large image at normal size</string>
    <string name="image_view_large_at_most">Large image scaled to at most 50x50</string>
    <string name="image_view_large_at_most_padded">Large image scaled to at most 70x70 with padding</string>
    <string name="image_view_large_exactly_padded">Large image scaled to exactly 70x70 with padding</string>
    <string name="image_view_small_normal">Small image at normal size</string>
    <string name="image_view_small_at_most">Small image scaled to at most 50x50</string>
    <string name="image_view_small_at_most_padded">Small image scaled to at most 70x70 with padding</string>
    <string name="image_view_small_exactly_padded">Small image scaled to exactly 70x70 with padding</string>

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
ProgressBar Demo1  (0) 2013.08.13
AutoText Demo 자동완성 텍스트뷰  (0) 2013.08.13
Spinner Demo  (0) 2013.08.13
Button Demo  (0) 2013.08.13

+ Recent posts