Android Studio中的大胆文字..只有一个字? java的

时间:2015-03-04 15:17:40

标签: java android text android-studio spinner

我有一个微调器,我需要在Bold中用它来表达它,以使其更具可读性。有没有人知道如何做到这一点? Iv尝试失败,因为我似乎只能使整个事情变得大胆。我想使用粗体这个词。

继承我的代码:

public class Interactions extends Activity implements OnItemSelectedListener {


Spinner spinner;
TextView showmed;
private String[] state = {"Adalimumab",
        "Etanercept",
        "Tacrolimus",
        "Mycophenolic Acid",
        "Bicalutamide",
        "Darbepoetin alfa",
        "Ciclosporin",
        "Interferon beta-1a",
        "Triptorelin",
        "Pegfilgrastim"
};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    if (MinderActivity.alarms) {
        setTheme(R.style.MyTheme);
    } else {
        setTheme(R.style.MyTheme);
    }
    setContentView(R.layout.activity_interactions);
    System.out.println(state.length);
    showmed = (TextView) findViewById(R.id.showmed);
    spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, state);
    adapter_state
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter_state);
    spinner.setOnItemSelectedListener(this);

}

public void onItemSelected(AdapterView<?> parent, View view, int position,
                           long id) {

    switch(position)
    {

        case 0:
            showmed.setText("Adalimumab\n" +
                            "Uses:\n" + "Treating a variety of moderate to severe inflammatory conditions (eg, rheumatoid arthritis, juvenile idiopathic arthritis [JIA], psoriatic arthritis, ankylosing spondylitis). It is also used to treat certain patients with moderate to severe Crohn disease, ulcerative colitis, or chronic plaque psoriasis. It may be used alone or in combination with other medicine. It may also be used for other conditions as determined by your doctor.\n" +
                            "\n" + "Alternative Names\n"+ "Humira\n"+ "Risks:\n"+ "Patients who use adalimumab have an increased risk of developing serious and sometimes fatal infections (eg, bacterial, viral, or fungal infections; tuberculosis [TB]). Most patients who developed these infections were also taking medicine that suppressed their immune system (eg, corticosteroids, methotrexate).\"TB may be caused by a new infection or by reactivation of a previous infection. Patients should receive a TB skin test before using adalimumab. Patients who test positive for TB should begin treatment for TB before starting adalimumab. All patients should also be monitored for signs of TB while using adalimumab, even if their TB test is negative.\n" +
                            "\n" + "Interactions\n"+ "\n"


            );
            break;

1 个答案:

答案 0 :(得分:0)

使用SpannableStringBuildernew StyleSpan(Typeface.BOLD)应用于您想要的文本部分。

或者,将该部分包装在<b>代码中并使用Html.fromHtml(),让它以粗体格式为您构建Spanned

相关问题