Android – Code is not working to set text of EditText to bold

Try..this code…

public class MainActivity extends Activity {


EditText ed;
Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ed=(EditText)findViewById(R.id.editText1);
    btn=(Button)findViewById(R.id.button1);


    btn.setOnClickListener(new OnClickListener() {

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

             Typeface tf = Typeface.createFromAsset(getAssets(),
                        "fonts/your.ttf");
               ed.getText().toString();
                ed.setTypeface(tf);

        }
    });
}

Put ur custom fonts in assets-> fonts folder…
Hope this will help u… it is working…

Leave a Comment