2013-08-02 240 views
1

在我的第四課堂選擇的文本將不會顯示粗體只有早餐會顯示粗體午餐和晚餐不是鞋大膽當我按img2或img3告訴我我會做什麼?所有值顯示在吐司,但只有當PRES IMG是做早餐會大膽午餐和晚餐沒有表現出不maketext大膽大膽在我的代碼textview不顯示大膽我該怎麼辦?

img1.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 

      Intent iMenuList = new Intent(thirdstep.this, 
        fourthscreen.class); 

      iMenuList.putExtra("Menuitem", txt1.getText().toString()); 

      startActivity(iMenuList); 

     } 
    }); 

    img2.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 

      Intent iMenuList = new Intent(thirdstep.this, 
        fourthscreen.class); 

      iMenuList.putExtra("Menuitem", txt2.getText().toString()); 

      startActivity(iMenuList); 

     } 
    }); 

    img3.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 

      Intent iMenuList = new Intent(thirdstep.this, 
        fourthscreen.class); 

      iMenuList.putExtra("Menuitem", txt3.getText().toString()); 

      startActivity(iMenuList); 

     } 
    }); 

} 

    } 


     public class fourthscreen extends Activity 

      Breakfast = (TextView) findViewById(R.id.txtfourth1); 
    Lunch = (TextView) findViewById(R.id.txtfourth2); 
    Supper = (TextView) findViewById(R.id.txtfourth3); 


     Bundle bundle = this.getIntent().getExtras(); 
    String param1 = bundle.getString("Menuitem"); 

       Toast.makeText(fourthscreen.this, param1, Toast.LENGTH_LONG).show(); 
    if(param1.equalsIgnoreCase("BreakFast")) 
    { 
     Breakfast.setTypeface(null, Typeface.BOLD); 
    } 
    else 
     if(param1.equalsIgnoreCase("Lunch")) 
     { 
      Lunch.setTypeface(null, Typeface.BOLD); 
     } 
     else 
      if(param1.equalsIgnoreCase("Supper")) 
      { 
       Lunch.setTypeface(null, Typeface.BOLD); 
      } 
+0

txt1.getText()的toString()=早餐txt2.getText()的toString()=午餐 – user2644835

+0

txt3.getText()的toString()= SUPPER – user2644835

+0

嘗試使用安卓。TEXTSTYLE = 「黑體」在XML – Sunny

回答

0

首先檢查String param1 = bundle.getString("Menuitem"); p * aram1 *值以下行,你只有通過「B reakFast「,」午餐「和」晚餐「?

if(param1.equalsIgnoreCase("BreakFast")) 
{ 
     Breakfast.setTypeface(null, Typeface.BOLD); 
     Lunch.setTypeface(null, Typeface.NORMAL); 
     Supper.setTypeface(null, Typeface.NORMAL); 
} 
else if(param1.equalsIgnoreCase("Lunch")) 
{ 
     Lunch.setTypeface(null, Typeface.BOLD); 
     Breakfast.setTypeface(null, Typeface.NORMAL); 
     Supper.setTypeface(null, Typeface.NORMAL); 
} 
else if(param1.equalsIgnoreCase("Supper")) 
{ 
     Supper.setTypeface(null, Typeface.BOLD); 
     Lunch.setTypeface(null, Typeface.NORMAL); 
     Breakfast.setTypeface(null, Typeface.NORMAL); 
} 
+0

是50%的工作午餐會不會b突出顯示 否則,如果(param1.equalsIgnoreCase(「午餐」)) \t { \t \t Breakfast.setTypeface(NULL,字體。正常); \t \t Lunch.setTypeface(null,Typeface.BOLD); \t \t Supper.setTypeface(null,Typeface.NORMAL); \t} – user2644835

+0

當我按img2 buttonToast將顯示「午餐」,但lunch.txt不會b大膽 – user2644835

+0

向我顯示您的最新代碼與xml文件.. –

0
yourTextView.setTypeface(null,Typeface.DEFAULT_BOLD); 

嘗試默認大膽的,它爲我工作

+0

不,我只是想按按鈕上的文字顯示西港島線大膽 – user2644835

0

在XML只是寫在TextView中標籤

android:textStyle="bold" 
相關問題