I want to create button with text = \"SomeText\" on center of this button and \"0\" on right part of button. Where \"0\" is the Counter and when I click this button Counter++ i
Try this way,hope this will help you to solve your problem.
main.xml
strings.xml
Some Text %1d
MyActivity.java
public class MyActivity extends Activity{
private Button btnCounter;
private int count;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnCounter = (Button) findViewById(R.id.btnCounter);
btnCounter.setText(String.format(getString(R.string.button_text),count));
btnCounter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count++;
btnCounter.setText(String.format(getString(R.string.button_text),count));
}
});
}
}