如何以编程方式将imageView添加到framelayout中

时间:2017-05-12 10:14:33

标签: android android-layout

您好,在我的xml文件中,我有一个包含textView和框架布局的relativeLayout:

makePdfAsync()

我想创建一个ImageView并以编程方式将其添加到框架布局中。 怎么做。 这是一个丰富的方法,它将完成这项工作:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="20dp">

        <EditText
            android:id="@+id/id_send_EditText"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:hint="@string/enter_text"
            android:textColorHint="@color/com_facebook_button_background_color_disabled"
            android:paddingRight="40dp"
            android:layout_alignParentBottom="true"
            android:isScrollContainer="true"/>
        <FrameLayout
            android:id="@+id/fl_pubCreate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </FrameLayout>
   </RelativeLayout>

2 个答案:

答案 0 :(得分:0)

简单添加

flayout.addView(imgMedia);

答案 1 :(得分:0)

这样做

<?php
    mysql_connect("localhost","root");
    mysql_select_db("simple");
    $id=$_POST['id'];
    $res=mysql_query("SELECT * FROM simple_tb WHERE id=$id");
    while($row=mysql_fetch_array($res))
    {
?>
    <link rel="stylesheet" type="text/css" href="demo.css" media="screen" /></head>
    <h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
    <h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
    <p align="center">Students Tuetion Fee Payment Sheet<br></p>
    <table class="table" align="center"width="800"  bgcolor="skyblue">
        <tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['id'];?></td></tr>
        <tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
        <tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
        <tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
    </table>
    <br>
    <h4 ALIGN="CENTER">PAYMENT STATUS</H4>
        <table align="center"width="800" BORDER="1" bgcolor="red">
            <tr>
                <td align="center"><B>DATES</B></td>
                <td align="center"><B>DESCRIPTION</B></td>
                <td align="center"><B>MEMO NO</B></td>
                <td align="center"><B>BDT</B></td>
                <td align="center"><B>Con.Total</B></td>
            </tr>
<?php

        $res2=mysql_query("SELECT * FROM ac WHERE sid=".$row['id']);
        while($row2=mysql_fetch_array($res2))
        {   $sum+= $row2['t'];
        ?>

            <tr bgcolor="cream">
                <td bgcolor="white"align="center"><?php echo $row2['d'];?></td>
                <td bgcolor="white"align="center"><?php echo $row2['des'];?></td>
                <td bgcolor="white"align="center"><?php echo $row2['m'];?></td> 
                <td bgcolor="white"align="center"><?php echo $row2['t'];?></td>
                <td bgcolor="white"align="center"><?php echo $sum."<br>";?></td>
                 <td bgcolor="white"align="center"></td>
            </tr>

<?php
        }
        ?></table><?php
    }