ListView, 체크 상자 및 회 전자를 하나의 레이아웃에두고 다른 레이아웃에서 XML에서 구문 분석하여 목록보기 항목을 호출했습니다. HTTP 게시물을 사용하여 체크 박스, 스피너 및 목록보기 항목 이름의 값을 집합 적으로 보내는 방법 설명을위한 세부 코드가 필요합니다. 여기 목록 항목과 회 전자 및 확인란의 HttpPost를 보내는 방법
여기public class Hut extends ListActivity {
static final String URL = "http://192.168.1.112/andro/index.php/androctrl/provider_detail/";
// XML node keys
static final String KEY_ITEM = "element"; // parent node
static final String KEY_ID = "foodjoint_id";
static final String KEY_NAME = "foodjoint_name";
static final String KEY_LAT = "foodjoint_latitude";
static final String KEY_DESC = "foodjoint_description";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pizzahut);
ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_ITEM);
// looping through all item nodes <item>
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(KEY_ID, parser.getValue(e, KEY_ID));
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
map.put(KEY_LAT, "Rs." + parser.getValue(e, KEY_LAT));
map.put(KEY_DESC, parser.getValue(e, KEY_DESC));
// adding HashList to ArrayList
menuItems.add(map);
}
// Adding menuItems to ListView
ListAdapter adapter = new SimpleAdapter(this, menuItems,
R.layout.list_item,
new String[] { KEY_NAME, KEY_DESC, KEY_LAT }, new int[] {
R.id.name, R.id.desciption, R.id.cost });
setListAdapter(adapter);
// selecting single ListView item
ListView lv = getListView();
}
//the continue button
public void onClick(View v)
{
Intent personal = new Intent(this, UserPersonal.class);
startActivity(personal);
}
여기
<?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"
android:background="@color/white" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="181dp"
android:layout_height="504dp"
android:background="@color/white"
android:gravity="fill"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="216dp"
android:layout_height="483dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
</ListView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/picktime" />
</RelativeLayout>
</ScrollView>
를 제출 내 목록보기 버튼 내 pizzahut.xml입니다 내가 목록보기로를 XML로 구문 분석 선언 한 나의 활동 내 list_item.xml입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="483dp"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/name"
android:layout_width="104dp"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#dc6800"
android:textSize="16sp"
android:textStyle="bold" />
<!-- Description label -->
<TextView
android:id="@+id/desciption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:paddingBottom="2dip">
</TextView>
<!-- Linear layout for cost and price Cost: Rs.100 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Cost Label -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#5d5d5d"
android:gravity="left"
android:textStyle="bold"
android:text="Cost: " >
</TextView>
<!-- Price Label -->
<TextView
android:id="@+id/cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:textStyle="bold"
android:gravity="left">
</TextView>
</LinearLayout>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="118dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
[pizzahut] 버튼을 클릭 할 때마다. xml 및 PizzaHut.java]
[xmlparsing에서 가져온] HTTPPost 메뉴 항목 이름에 체크 상자 값을 선택하면 스피너 값이 함께 나타납니다. 전체 설명을 제공하십시오. 난 당신이 제목, XML parsing.You에서 설명 및 비용 값이 XML에서이 값이 코드를
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HashMap<String, String> data = menuItems.get(position);
String title = data.get("foodjoint_name");
String description = data.get("foodjoint_description");
String price = data.get("foodjoint_latitude");
Intent personal = new Intent(this, UserPersonal.class);
startActivity(personal);
in.putExtra("title", title);
in.putExtra("descp", description);
in.putExtra("DURATION", pubdate);
in.putExtra("URL", imagename);
startActivity(personal);
}
});
에 따라 다른 활동에 전달할 수지고 있음을 발견하여 위의 코드에서