android 학습 노트 21 ---------- RelativeLayout + ListView
효과 도
 
   public class ListViewActivity extends ListActivity
{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.main);
		SimpleAdapter adapter = new SimpleAdapter(this, getData(),
				R.layout.main, new String[]
				{"title","info","img"}, new int[]
				{ R.id.title, R.id.info, R.id.img });
		setListAdapter(adapter);
	}
	private List<Map<String, Object>> getData()
	{
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("title", "G1");
		map.put("info", "google 1");
		map.put("img", R.drawable.icon);
		list.add(map);
		map = new HashMap<String, Object>();
		map.put("title", "G2");
		map.put("info", "google 2");
		map.put("img", R.drawable.icon);
		list.add(map);
		map = new HashMap<String, Object>();
		map.put("title", "G3");
		map.put("info", "google 3");
		map.put("img", R.drawable.icon);
		list.add(map);
		return list;
	}
}<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<RelativeLayout 
		android:orientation="vertical"
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content">
		 
		 <ImageView 
		 	android:id="@+id/img"         
		 	android:layout_width="wrap_content"       
		 	android:layout_height="wrap_content"         
		 	android:layout_margin="2px"/>
		 	
		<TextView 
			android:id="@+id/title" 
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" 
			android:layout_toRightOf="@id/img"
			android:textColor="#FFFFFFFF"
			android:textSize="22px" />
			
		<TextView 
			android:id="@+id/info" 
			android:layout_toRightOf="@id/img"
			android:layout_alignBottom="@id/img"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" 
			android:textColor="#FFFFFFFF"
			android:textSize="13px" />
	</RelativeLayout>
</LinearLayout>ListActivity 에 setListAdapter () 방법 이 있 습 니 다.
// ListView 中某项被选中后的逻辑    	@Override
	protected void onListItemClick(ListView l, View v, int position, long id)
	{
		Log.v("MyListView4-click", (String) mData.get(position).get("title"));
	}
 
   
                
                    
        
    
    
    
    
    
                
                
                
                
                
                
                    
                        
                            
                            
                                
                                    
                                    이 내용에 흥미가 있습니까?
                                
                            
                            
                            
                            현재 기사가 여러분의 문제를 해결하지 못하는 경우  AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
                            
                                
                                Kotlin의 기초 - 2부
                            
                            지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다.
유형 변환은 데이터 변수의 한 유형을 다른 데이터...
                            
                            
                            
                            
                            텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.