在我的代码textview中没有显示粗体我将做什么?

时间:2013-08-02 07:19:15

标签: android

在我的第四课选择的文字中不会显示粗体只有早餐会显示大胆午餐和晚餐不是鞋子大胆我按img2或img3告诉我我会怎么做?所有价值观都显示在Toast上但不是maketext粗体只有当img是make时早餐会是大胆的午餐和晚餐不显示粗体

  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);
             }

3 个答案:

答案 0 :(得分:0)

yourTextView.setTypeface(null,Typeface.DEFAULT_BOLD);

尝试默认粗体,它适用于我

答案 1 :(得分:0)

在xml中,只需在TextView标记

中编写以下行
android:textStyle="bold"

答案 2 :(得分:0)

首先检查String param1 = bundle.getString("Menuitem"); p * aram1 *值,你只传递“BreakFast”,“Lunch”和“Supper”吗?

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);
}