如何更改listview的文本大小

 123妖_精 发布于 2023-02-12 10:47

我正在使用List Activity从SQLITE中检索数据.但我无法设置列表视图的字体大小.请帮我.

public class CartList extends ListActivity {
    private ArrayList results = new ArrayList();
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(com.example.easyshopping.R.layout.cart);
        openAndQueryDatabase();
        displayResultList();
    }
    private void displayResultList() {
        setListAdapter(new ArrayAdapter(this,
                android.R.layout.simple_list_item_1, results));
        getListView().setTextFilterEnabled(true);   }
        private void openAndQueryDatabase() {
        try {
            SQLiteDatabase database = openOrCreateDatabase("ORCL", MODE_PRIVATE, null);
            Cursor c = database.rawQuery("SELECT title,qty,price FROM CART;", null);
                         if (c != null ) {
                int totalPrice=0;
                if  (c.moveToFirst()) {
                    do {
                        String title = c.getString(c.getColumnIndex("title"));
                        int qty = c.getInt(c.getColumnIndex("qty"));
                        int price = c.getInt(c.getColumnIndex("price"));
                        int pricePerTitle=price*qty;
                        results.add("Title: " + title + ",  Quantity: " + qty+",  Price: $"+pricePerTitle);
                        totalPrice=totalPrice+pricePerTitle;
                    }while (c.moveToNext());
                }
               TextView tTotalPrice=(TextView)findViewById(com.example.easyshopping.R.id.txttotalprice);
                String total= Integer.toString(totalPrice);
               tTotalPrice.setText(total);
            }
        } catch (SQLiteException se ) {
            Log.e(getClass().getSimpleName(), "Could not create or Open the database");
        }

    }

cart.xml

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_
              android:layout_>
    
        

            

    

    
       
        
        

            

列表视图中的字体大小非常大. 在此输入图像描述

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有