android - 如何在第二个 activity2 的 ListView 末尾添加两个按钮?

标签 android

如何在第二个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>

最佳答案

就像评论中的一个人所说的那样,如果你想做这样的事情:

Image example

您必须将类从 ListActivity 更改为 ActivityActionBarActivity .之后,在您的 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/

相关文章:

android - 意外的 android 应用程序终止而没有崩溃异常

java - 使用 while()+sleep() 代替信号量或互斥量?

android - 为什么 Firebase 可以在没有互联网许可的情况下在我的应用程序上运行

android - ADB上生成Android ID的方法是什么

android - 无法在android studio中导入mockito

java - Android/OpenGL glRotatef 使用 GLOrthof 时没有视角

android - 如何以编程方式获取 RotateDrawable 的轴心?

java - Android - 为什么我们应该使用 adapter.notifydatasetChanged() 方法?

android - 将图像从 drawable 保存到 Android 中的内部文件存储

android - android项目最好的静态代码分析工具是什么?