2015-06-05 97 views
-2

我在android textview中遇到問題。 我只是對Android的TextView設置文本像下面顯示爲空輸出的Android Textview

  pAmount.setText("Rs." + receiptAmount + "/-"); 

,而是顯示在文本

   System.out.println("receiptAmount ====>"+ receiptAmount); 

我曾試圖打印receiptAmount的值,以檢查是否爲空,則該值爲空或不。 但是,它在日誌中顯示正確的值。 任何機構有什麼想法是什麼問題。 同樣,其他texview在相同的活動中顯示空值。

+3

用完整代碼編輯您的問題 – RaMeSh

+1

receiptAmount爲null的原因。你需要爲此發佈代碼。 – Amsheer

+0

請發佈您的完整代碼,並且是receiptAmiunt字符串,int等。 –

回答

0
TextView pAmount= (TextView) findViewById(R.id.amount); 

1.調用設置文本在Oncreate中聲明上述行之後。

2.獲取receiptAmount中的正確數據。你的問題就解決了

pAmount.setText("Rs." + receiptAmount + "/-"); 
0
public void FeeGetFeeTypes(String studentId, String fee_slotid) { 
    // TODO Auto-generated method stub 
    ArrayList<String> arrayList_FeeType=new ArrayList<String>(); 
    ArrayList<String> arrayList_FeeTypeAmount=new ArrayList<String>(); 
    try{ 
     SQLiteDatabase db = this.getReadableDatabase(); 

    final String MY_QUERY = "select * from feetype where student_id=? and slot_id=?"; 
    Cursor res = db.rawQuery(MY_QUERY, new String[]{ studentId, fee_slotid }); 
    res.moveToFirst(); 
    while (res.isAfterLast() == false){ 
     arrayList_FeeType.add(res.getString(res 
       .getColumnIndex(FEE_TYPE_COLUMN_FEETYPE))); 

     arrayList_FeeTypeAmount.add(res.getString(res 
       .getColumnIndex(FEE_TYPE_COLUMN_FEETYPEAMOUNT))); 
    } 
    if(arrayList_FeeType.size()>0){ 
     PrintActivity.sendFeeType(arrayList_FeeType, arrayList_FeeTypeAmount); 
    } 
    } 
    catch(Exception e){ 
     e.printStackTrace(); 
    } 
} 

這是導致空值的代碼。當數據很大時,我得到內存不足異常