开发者社区> 问答> 正文

小白学android的,提示栏没有出现text的内容

本人是新手,在自学阶段,看了一段代码,在重写之后发现提示栏没有出现预期段内容。求教各位大神这是怎么回事?

这个是activity中段主要函数

public void showCustomDialog()   

    {   

        AlertDialog.Builder builder;   

        AlertDialog alertDialog;   

        Context mContext = MainActivity.this;   

  

        LayoutInflater inflater = (LayoutInflater)    

        mContext.getSystemService(LAYOUT_INFLATER_SERVICE);   

        View layout = inflater.inflate(R.layout.custom_dialog,null);   

        TextView text = (TextView) layout.findViewById(R.id.text);   

        ImageView image = (ImageView) layout.findViewById(R.id.image);   

        image.setImageResource(R.drawable.ic_launcher);   

        builder = new AlertDialog.Builder(mContext);   

        builder.setView(layout);   

        alertDialog = builder.create();   

        alertDialog.show();  

        //无法显示text的内容? 

    } 

这个是我在第二个xml中段内容


<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 

    android:layout_height="match_parent" 

    android:orientation="vertical" > 

    <ImageView  

        android:layout_width="wrap_content" 

        android:layout_height="fill_parent" 

        android:id="@+id/image" 

        android:layout_marginRight="10dp"/> 

    <TextView  

        android:layout_width="wrap_content" 

        android:layout_height="fill_parent" 

        android:id="@+id/text" 

        android:textColor="#FFF" 

        android:text="sucess"/>    

</LinearLayout> 

请教啊,这是怎么回事呢???
我是在MacBook Air 下运行段,此外,问一下在这个环境下,怎么将虚拟机联网,?

展开
收起
爵霸 2016-06-06 11:25:52 2021 0
1 条回答
写回答
取消 提交回答
  • 你的ImageView已经的layout_height已经是fill_parent 下面的TextView就没地方放了, 把你的ImageView的layout_height设置成wrap_content,解决了请设为满意回答

    2019-07-17 19:28:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载