Alternatif olarak tasarımınızı aşağıda gösterilen şekilde doğrudan kodunuzun içinde de yaratabilirsiniz.
package
com.example.hello_world;
import
android.os.Bundle;
import
android.app.Activity;
import
android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
LinearLayout.LayoutParams textViewLP = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TextView myTextView = new TextView(this);
myTextView.setText("Hello
World, HelloWorld");
ll.addView(myTextView, textViewLP);
addContentView(ll, lp);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Yorumlar
Yorum Gönder