
我在我的项目中使用列表视图,其中我使用了一个用于创建列表项的xml文件.然后我在由ListActivity扩展的类中以编程方式使用了它.
但是问题是我必须在屏幕底部添加一个与列表视图无关的按钮,但是列表视图覆盖了所有屏幕.
所以,有什么办法可以在android中以列表视图在底部添加按钮.
我的代码是:-
@H_403_10@import androID.app.ListActivity;import androID.content.Intent;import androID.os.Bundle;import androID.Widget.AdapterVIEw;import androID.Widget.ArrayAdapter;import androID.Widget.ImageVIEw;import androID.Widget.ListVIEw;import androID.Widget.TextVIEw;import androID.Widget.Toast;import androID.Widget.AdapterVIEw.OnItemClickListener;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.vIEw.Window;public class Options extends ListActivity { String[] items; @OverrIDe public voID onCreate(Bundle icicle) { super.onCreate(icicle); requestwindowFeature(Window.FEATURE_RIGHT_ICON); items = getResources().getStringArray(R.array.chantoption_array); setlistadapter(new IconicAdapter()); ListVIEw lv = getListVIEw(); lv.setTextFilterEnabled(true); lv.setBackgroundResource(R.drawable.ichant_logo); setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON, R.drawable.icon_t); lv.setonItemClickListener(new OnItemClickListener() { public voID onItemClick(AdapterVIEw<?> parent, VIEw vIEw, int position, long ID) { // When clicked, show a toast with the TextVIEw text Toast.makeText(getApplicationContext(), items[position], Toast.LENGTH_SHORT).show(); if ("Gayatri Mantra".equals(items[position].toString())) { int[] timeintervals = { 23900, 24000 }; // startChantActivity(TotalMala_loop,Total_Bead_Loop,BacgroundImage,Icon,Title,BeadsTotalTimeIntervals+totalTimeDurationOfAudio) startChantActivity(2, 108, R.drawable.gayatri, R.raw.gayatri, R.drawable.icon_gayatri, "Gayatri Mantra", timeintervals); } if ("Om Mani Padme Hum".equals(items[position].toString())) { int[] timeintervals = { 5500, 8200, 11100, 13900, 34100, 36700, 39500, 42300, 59300, 62000, 64800, 67600, 124600 }; // startChantActivity(TotalMala_loop,Total_Bead_Loop,BacgroundImage,Icon,Title,BeadsTotalTimeIntervals+totalTimeDurationOfAudio) startChantActivity(2, 108, R.drawable.ommanipadmehum, R.raw.om_mani, R.drawable.icon_padme, "Om Mani Padme Hum", timeintervals); } if ("Sai Ram".equals(items[position].toString())) { // Audio time interval for bead+total time duration of audio int[] timeintervals = { 4800, 7500, 10400, 12600, 15800, 18600, 21600, 24400, 25000 }; // startChantActivity(TotalMala_loop,Total_Bead_Loop,BacgroundImage,Icon,Title,BeadsTotalTimeIntervals+totalTimeDurationOfAudio) startChantActivity(2, 108, R.drawable.sairam, R.raw.sairam, R.drawable.icon_sairam, "Sai Ram", timeintervals); } if ("Aum".equals(items[position].toString())) { // Audio time interval for bead+total time duration of audio int[] timeintervals = { 12850, 13000 }; // startChantActivity(TotalMala_loop,Total_Bead_Loop,BacgroundImage,Icon,Title,BeadsTotalTimeIntervals+totalTimeDurationOfAudio) startChantActivity(2, 108, R.drawable.aum, R.raw.aum, R.drawable.ico_aum, "Aum", timeintervals); } } }); } class IconicAdapter extends ArrayAdapter { IconicAdapter() { super(Options.this, R.layout.List_item, items); } public VIEw getVIEw(int position, VIEw convertVIEw, VIEwGroup parent) { LayoutInflater inflater = getLayoutInflater(); VIEw row = inflater.inflate(R.layout.List_item, parent, false); TextVIEw label = (TextVIEw) row.findVIEwByID(R.ID.label); label.setText(" "+items[position]); ImageVIEw icon = (ImageVIEw) row.findVIEwByID(R.ID.icon); if (items[position].equals("Gayatri Mantra")) { icon.se@R_403_5411@Resource(R.drawable.icon_gayatri); } if (items[position].equals("Om Mani Padme Hum")) { icon.se@R_403_5411@Resource(R.drawable.icon_padme); } if (items[position].equals("Sai Ram")) { icon.se@R_403_5411@Resource(R.drawable.icon_sairam); } if (items[position].equals("Aum")) { icon.se@R_403_5411@Resource(R.drawable.ico_aum); } return (row); } } protected voID startChantActivity(int mala_loop, int beads_loop, int background, int media, int TitleIcon, String Title, int[] timeintervals) { Bundle bundle = new Bundle(); bundle.putInt("mala_loop", mala_loop); bundle.putInt("beads_loop", beads_loop); bundle.putInt("background", background); bundle.putInt("media", media); bundle.putInt("TitleIcon", TitleIcon); bundle.putString("Title", Title); bundle.putIntArray("intervals", timeintervals); Intent intent = new Intent(this, ChantBliss.class); intent.putExtras(bundle); startActivityForResult(intent, this.getSelectedItemposition()); }}相应的xml文件是:
@H_403_10@<?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"><ImageVIEwandroID:ID="@+ID/icon"androID:layout_wIDth="wrap_content"androID:paddingleft="2px"androID:paddingRight="2px"androID:paddingtop="2px"androID:layout_height="wrap_content"/><TextVIEwandroID:ID="@+ID/label"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:textSize="22sp"androID:textcolor="#ff000000"/></linearLayout>
提前致谢:
桑迪普
解决方法:
这样的事情对我有用:
@H_403_10@<?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" ><ListVIEw androID:ID="@+ID/List" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:layout_weight="1" androID:drawSelectorOntop="false"/><linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" > <EditText androID:ID="@+ID/newfilter" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_weight="1" androID:hint="Add a filter" /> <button androID:ID="@+ID/addit" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="fill_horizontal" androID:drawableleft="@drawable/btn_plus_pressed" /> </linearLayout> </linearLayout>总结
以上是内存溢出为你收集整理的设置列表视图大小Android全部内容,希望文章能够帮你解决设置列表视图大小Android所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)