源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

手写android布局示例

  • 时间:2021-03-03 21:58 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:手写android布局示例
[u]复制代码[/u] 代码如下:
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);         } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部