I have tried to do like this,
findViewById(R.id.button1).setText("HI");
But it is not working. is there any other way to do it?
Try this
((Button) findViewByid(R.id.button1)).setText("Hi");
If you are trying to instantiate button inside subclass like adapters or dialogs etc , use the respective view before findViewByid.
((Button) view.findViewByid(R.id.button1)).setText("Hi");
or
((Button) dialog.findViewByid(R.id.button1)).setText("Hi");