Alhamdulillah,最后我可以结合按钮,创艺,使用RelativeLayout的通过编码。这是源代码。
public class Diagram extends Activity {
/** Called when the activity is first created. */
grafik mgrafik;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout rel = new RelativeLayout (this);
rel.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
mgrafik = new grafik(this);
RelativeLayout.LayoutParams grf = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
grf.addRule(RelativeLayout.CENTER_HORIZONTAL);
Button btn = new Button(this);
btn.setText("Kembali");
RelativeLayout.LayoutParams pbtn = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
pbtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rel.addView(mgrafik, grf);
rel.addView(btn, pbtn);
setContentView(rel);
}
}
感谢的一切对你有所帮助。
我试过它在绝对平铺它没有错误。但是当我在android模拟器上运行该程序时,它表示该活动意外停止并需要关闭。任何其他想法? – abdurrahman
可能因为您没有添加第二个构造函数。什么是堆栈跟踪? – mibollma
我应该如何把第二个构造函数?什么是堆栈跟踪?是这[2011-08-16 08:05:43 - CobaPass]安装CobaPass.apk ... [2011-08-16 08:06:25 - CobaPass]成功! [2011-08-16 08:06:25 - CobaPass]开始活动设备模拟器上的coba.pass.CobaPassActivity -5554 [2011-08-16 08:06:27 - CobaPass] ActivityManager:开始:意图{act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = coba.pass/.CobaPassActivity} – abdurrahman