手寫android布局示例
package com.test;
import android.app.Activity;
import android.os.Bundle;
//import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
//import android.widget.Toast;
public class Test_javaActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
// layout.setOrientation(LinearLayout.VERTICAL);
Button button = new Button(this);
button.setText("Click Me");
button.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
/** button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(Test_javaActivity.this, "Button Clicked",
Toast.LENGTH_LONG).show();
}
});
*/
layout.addView(button);
setContentView(layout);
}
}
相關文章
Eclipse下配置Ant腳本并自動打包帶簽名的Android apk
這篇文章主要介紹了Eclipse下配置Ant腳本并自動打包帶簽名的Android apk的相關資料,需要的朋友可以參考下2016-03-03
Android Back鍵點擊兩次退出應用詳解及實現(xiàn)方法總結
這篇文章主要介紹了Android Back鍵點擊兩次退出應用詳解及實現(xiàn)方法總結的相關資料,需要的朋友可以參考下2016-10-10
Android如何通過Retrofit提交Json格式數(shù)據(jù)
本篇文章主要介紹了Android如何通過Retrofit提交Json格式數(shù)據(jù),具有一定的參考價值,有興趣的可以了解一下2017-08-08
Android Studio下載更新Android SDK網絡異?;驘o法下載
這篇文章主要介紹了Android Studio下載更新Android SDK網絡異常或無法下載的相關資料,需要的朋友可以參考下2017-04-04
代碼從windows下visual studio到andriod平臺遷移實現(xiàn)步驟
這篇文章主要介紹了代碼從windows下visual studio到andriod平臺遷移的修改記錄的相關資料,需要的朋友可以參考下2017-01-01

