活动未显示
我有一个带有各种项目的线性布局的活动,但是当我运行该应用程序时,我没有显示任何内容。
请帮忙:-)
<LinearLayout
mlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/TitleBarLayOut"
android:background="@drawable/titlebar_gradient">
</LinearLayout>
<LinearLayout android:id="@+id/topLayout" android:layout_width="fill_parent" android:layout_height="70px" android:background="#FFFFFF">
<ImageView android:id="@+id/coverArt" android:layout_width="60px" android:layout_height="60px" android:paddingLeft="10px" android:paddingTop="10px"></ImageView>
<TextView android:layout_width="fill_parent" android:id="@+id/playlistTitle" android:text="TextView" android:layout_height="30px"></TextView>
<TextView android:layout_width="fill_parent" android:id="@+id/playlistMember" android:text="TextView" android:layout_height="30px"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/bottomLayout" android:layout_width="fill_parent" android:layout_height="70px" android:background="#FFFFFF">
<TextView android:layout_width="fill_parent" android:id="@+id/playlistDescriptions" android:text="TextView" android:layout_height="fill_parent"></TextView>
</LinearLayout>
</LinearLayout>
setContentView(R.layout.playlistview);
Display display = getWindowManager().getDefaultDisplay();
int screenWidth = display.getWidth();
LinearLayout titlebar = (LinearLayout) findViewById(R.id.TitleBarLayOut);
FeaturedButton = new Button(this);
FeaturedButton.setText("Featured");
FeaturedButton.setGravity(Gravity.LEFT);
int FeaturedButtonWidth = 50;
playButton = new Button( this );
playButton.setText("Play");
playButton.setGravity(Gravity.RIGHT);
int playButtonWidth = 50;
int titleTextWidth = ((screenWidth-playButtonWidth)-FeaturedButtonWidth);
titleText = new TextView(this);
titleText.setGravity(Gravity.CENTER);
titleText.setTextColor(Color.WHITE);
titleText.setTextSize(14);
titleText.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD), Typeface.BOLD);
titlebar.addView(FeaturedButton, new LinearLayout.LayoutParams(
50, LayoutParams.WRAP_CONTENT));
titlebar.addView(titleText, new LinearLayout.LayoutParams(
titleTextWidth, LayoutParams.WRAP_CONTENT));
titlebar.addView(playButton, new LinearLayout.LayoutParams(
50, LayoutParams.WRAP_CONTENT));
CoverArtDisplay = (ImageView) findViewById(R.id.coverArt);
PlaylistTitleDisplay = (TextView) findViewById(R.id.playlistTitle);
PlaylistMemberDisplay = (TextView) findViewById(R.id.playlistMember);
PlaylistDescriptionsDisplay = (TextView) findViewById(R.id.playlistDescriptions);
I have an activity with a linear layout with various items but when i run the app i dont get anything displayed.
Please help :-)
<LinearLayout
mlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/TitleBarLayOut"
android:background="@drawable/titlebar_gradient">
</LinearLayout>
<LinearLayout android:id="@+id/topLayout" android:layout_width="fill_parent" android:layout_height="70px" android:background="#FFFFFF">
<ImageView android:id="@+id/coverArt" android:layout_width="60px" android:layout_height="60px" android:paddingLeft="10px" android:paddingTop="10px"></ImageView>
<TextView android:layout_width="fill_parent" android:id="@+id/playlistTitle" android:text="TextView" android:layout_height="30px"></TextView>
<TextView android:layout_width="fill_parent" android:id="@+id/playlistMember" android:text="TextView" android:layout_height="30px"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/bottomLayout" android:layout_width="fill_parent" android:layout_height="70px" android:background="#FFFFFF">
<TextView android:layout_width="fill_parent" android:id="@+id/playlistDescriptions" android:text="TextView" android:layout_height="fill_parent"></TextView>
</LinearLayout>
</LinearLayout>
setContentView(R.layout.playlistview);
Display display = getWindowManager().getDefaultDisplay();
int screenWidth = display.getWidth();
LinearLayout titlebar = (LinearLayout) findViewById(R.id.TitleBarLayOut);
FeaturedButton = new Button(this);
FeaturedButton.setText("Featured");
FeaturedButton.setGravity(Gravity.LEFT);
int FeaturedButtonWidth = 50;
playButton = new Button( this );
playButton.setText("Play");
playButton.setGravity(Gravity.RIGHT);
int playButtonWidth = 50;
int titleTextWidth = ((screenWidth-playButtonWidth)-FeaturedButtonWidth);
titleText = new TextView(this);
titleText.setGravity(Gravity.CENTER);
titleText.setTextColor(Color.WHITE);
titleText.setTextSize(14);
titleText.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD), Typeface.BOLD);
titlebar.addView(FeaturedButton, new LinearLayout.LayoutParams(
50, LayoutParams.WRAP_CONTENT));
titlebar.addView(titleText, new LinearLayout.LayoutParams(
titleTextWidth, LayoutParams.WRAP_CONTENT));
titlebar.addView(playButton, new LinearLayout.LayoutParams(
50, LayoutParams.WRAP_CONTENT));
CoverArtDisplay = (ImageView) findViewById(R.id.coverArt);
PlaylistTitleDisplay = (TextView) findViewById(R.id.playlistTitle);
PlaylistMemberDisplay = (TextView) findViewById(R.id.playlistMember);
PlaylistDescriptionsDisplay = (TextView) findViewById(R.id.playlistDescriptions);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经运行了你的项目,我认为你缺少:
在你的主 LinearLayout 中。如果添加它,则会显示带有文本视图的底部线性布局。
无论如何设计都不好。将按钮移至 XML,并请重新考虑您的布局;)
希望有帮助。
I've run your project and I think you are missing:
in your main LinearLayout. If you add it, the bottom linear layout with the textviews is displayed.
Anyway the design is not good. Move the buttons to XML and please rethink your layout ;)
Hope it helps.
信息如此之少,很难判断问题出在哪里。您是否使用带有 Android 插件的 Eclipse?
“我没有显示任何内容”是什么意思?应用程序是否运行,但您只看到空白视图?
您的活动是否在 AndroidManifest.xml 中列出?
Hard to tell what the problem is with so little information. Are you using Eclipse with the Android plugin?
What do you mean by "i dont get anything displayed"? Does the app run, but you just get a blank view?
Is your activity listed in AndroidManifest.xml?