-1
我試圖把編程線性佈局內垂直一個的LinearLayout,但似乎它不工作,那並不出現的按鈕,但文本視圖顯示...的LinearLayout水平內的LinearLayout垂直
這裏是我的代碼: (這是一個對話框。)
LinearLayout titleLayout = new LinearLayout(m_context);
titleLayout.setOrientation(LinearLayout.VERTICAL);
m_titleView = new TextView(m_context);
m_titleView.setText(title);
LinearLayout horizontalLayout = new LinearLayout(m_context);
titleLayout.setOrientation(LinearLayout.HORIZONTAL);
Button backward = new Button(m_context);
backward.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
backward.setText("Backwards");
Button newDirButton = new Button(m_context);
newDirButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
newDirButton.setText("New folder");
horizontalLayout.addView(backward);
horizontalLayout.addView(newDirButton);
titleLayout.addView(m_titleView);
titleLayout.addView(horizontalLayout);
提前感謝!
謝謝您的回答,它是在第六線misstype,它應該是horizontalLayout.setOrientation(LinearLayout.HORIZONTAL);不是titleLayout.setOrientation(LinearLayout.HORIZONTAL);大聲笑.. – TiagoM 2013-04-20 19:49:33
這隻顯示這個代碼是如何維護的;)您可能想要將您的評論移至答案並接受它。 – 2013-04-20 19:51:17
是的你是對的,不,我會接受你的努力;) – TiagoM 2013-04-20 20:04:14