i would like to create a custom button like this:
http://i77.photobucket.com/albums/j74/bertyhell/button.png?t=1279626910
but that doesn't work i need to show the text on the buttons with absolute positioning relative to the buttons origin all strings need to be changeable at runtime
but the button below can be a regular button
how can i do this?
if i create a button by inheriting from android.widget.button i have to draw the whole button myself?
is there an easier way?
EDIT
ok i tried the inherit from relative layout
like this:
package be.smarttelecom.datacheck.views;
import android.content.Context;
import android.util.Log;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class AlertButton extends RelativeLayout {
private TextView roomNumber;
public AlertButton(Context context, String roomNumber) {
super(context);
try{
this.alertId = alertId;
// TODO Auto-generated constructor stub
this.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView room = new TextView(context);
room.setFocusable(false);
room.setText(R.string.room);
room.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
this.roomNumber = new TextView(context);
this.roomNumber.setFocusable(false);
this.roomNumber.setId(R.id.roomNumber);
this.roomNumber.setTextSize(26);
this.roomNumber.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
this.roomNumber.setText(roomNumber);
}catch(Exception ex){
Log.i("test", "problem during construction of alert button: " + ex.getMessage());
}
}
public void setRoomNumber(String number){
roomNumber.setText(number);
}
public void setDescription(String description){
this.description.setText(description);
}
}
when i add it like this:
TableRow row2 = new TableRow(this);
AlertButton alert = new AlertButton(this, "1","14","wc","krist");
row2.addView(alert);
container.addView(row2, 0);
i get an empty page and no errors at all
any idea what i did wrong?
how do i put the textfields on certain positions? put them inside an absolute layout and add x an y coordinates? (absolute layout is depricated, alternative?)