如何在第二个activity2的listview末尾添加两个按钮
类:
public class PedidosListActivity extends ListActivity implements AdapterView.OnItemClickListener,SimpleAdapter.ViewBinder {
private Button buttonAdicionarProduto;
public class PedidosListActivity extends ListActivity implements
AdapterView.OnItemClickListener,SimpleAdapter.ViewBinder {
private Button buttonAdicionarProduto;
private static final List<Map<String, Object>> produtos = new ArrayList<Map<String, Object>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this, produtos, R.layout.pedidos_list, de, para);
adapter.setViewBinder(this);
setListAdapter(adapter);
XML:
它由四个部分组成: ImageView 和三个 TextView 我使用了 List Activity Activity,但是当我可以在屏幕上看到时,却没有适配器。使用适配器我不知道 View 准备好处理的时间
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/query_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="br.edu.ifpe.pdm.cardapiolanches.PedidosListActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imagem_produto"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/nome_produto"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/peso"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/preco"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
最佳答案
就像评论中的一个人所说的那样,如果你想做这样的事情:
您必须将类从 ListActivity 更改为 Activity
或 ActionBarActivity
.之后,在您的 XML 文件中尝试类似的操作:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_id"
android:text="@string/home_text_2"
android:textStyle="bold"/>
<ListView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/lv_id"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:background="@drawable/button_default"
android:textColor="@color/white"
android:layout_gravity="center"
android:text="Button Text"
android:id="@+id/bt_1"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1" />
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_default"
android:textColor="@color/white"
android:layout_gravity="center_vertical"
android:text="Button Text"
android:id="@+id/bt_2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
关于android - 如何在第二个 activity2 的 ListView 末尾添加两个按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30063651/