사용자 지정 listview를 만들고 ListActivity를 확장하여 정상적으로 작동합니다. 하지만 Activity를 확장하는 주요 활동에 ListView를 추가하려고합니다. 어떻게해야합니까?사용자 지정 목록보기 사용
예를 들어 ListActivity를 확장하는 하나의 ListView로 채워진 화면이 아니라 내 화면의 일부에 사용자 지정 ListView를 넣을 수 있습니다.
<?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">
<TextView
android:id="@+id/lvresult"
android:paddingTop="2dip"
android:paddingBottom="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
이이 MyListActivity입니다 :
package Dic.proj.pkg;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MyListActivity extends ListActivity {
EditText et;
TextView tv;
TextView tvresult;
String resulttext;
ArrayList<String> mArrayList = new ArrayList<String>();
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
// Use your own layout
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.customlist, R.id.lvresult, values);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
}
이 잘 작동하지만 화면에 하나의 목록보기를 볼 수 있습니다. 내 기본 활동에이 사용자 정의 목록보기를 넣고 싶습니다. 어떻게해야합니까?
당신은 구글나요? [Android의 맞춤 목록보기 예] (http://www.google.co.in/#hl=ko&safe=active&sclient=psy-ab&q=custom+listview+example+in+android&oq=custom+list&aq=1&aqi=g4&aql=&gs_sm = 3 = gs_upl 182417l185071l1l186944l15l10l2l3l4l1l183l1619l0.10l15l0 및 gs_l = hp.3.1.0l4.182417l185071l1l186944l15l10l2l3l4l1l183l1619l0j10l15l0 및 PBX = 1 BAV = on.2, or.r_gc.r_pw.r_qf., cf.osb 및 FP = bb4200f2eeeb84b9 및 BIW = 1280 & BIH = 677 및 안전 = ON) –