View.Invisible - 图像停留在屏幕上

时间:2012-04-28 20:21:22

标签: android xml view visibility

我尝试设置我的imageview,按钮和textview的可见性。但是当我运行该程序时,它们仍然存在。 我尝试了View.GONE,但只删除了所有textview,imageview和按钮。但我只想隐藏然后表现出来。

               list.setOnItemClickListener(new AdapterView.OnItemClickListener() 
            {
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int position, long arg3) 
                {
                                                if(baglanti.DegerDogruMu() == true)
                        {
                            ekvar = true; **// If true there is an attachment**
                            gelen = baglanti.EkinIsmi();
                        }
                        else
                        {
                            ekvar = false; **// False = no attachment**
                        }

                                }

然后我将结果放在意图中。

final Intent intent = new Intent(ListeleActivity.this, GoruntuleActivity.class);
intent.putExtra(ekvarmı, ekvar);
startActivity(intent);

和其他活动 通过添加“ekvar”

来调用此方法
    public void ListOnClicklendiginde(final int position , ArrayList<String> bodyliste , ArrayList<String> kimdenlist , ArrayList<String> konulist, boolean ekvarmı  , ArrayList<String> ekinismi)
        {
**// First I hide the "attachment things"**


   dosyaAdi.setVisibility(View.INVISIBLE);
        atacResim.setVisibility(View.INVISIBLE);
        ekButton.setVisibility(View.INVISIBLE);

**// If there is an attachment then visible the things. (I debug for the no attachment email and it fall the false so the statement is working ok)**


    if( ekvarmı == true)
                {
                    dosyaAdi.setVisibility(View.VISIBLE);
                    atacResim.setVisibility(View.VISIBLE);
                    ekButton.setVisibility(View.VISIBLE);

                }
                else
                {
                    dosyaAdi.setVisibility(View.INVISIBLE);
                    atacResim.setVisibility(View.INVISIBLE);
                    ekButton.setVisibility(View.INVISIBLE);
                }
                 }

XML:

<RelativeLayout
        android:id="@+id/ekTablo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_x="8dp"
        android:layout_y="102dp" >

        <ImageView
            android:id="@+id/imageViewAttachment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_email_attachment" />

        <TextView
            android:id="@+id/dosyaAdi"
            android:layout_width="210dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <ImageButton
            android:id="@+id/imageButtonEkIndir"
            android:layout_width="50dp"
            android:layout_height="16dp"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/dosyaAdi"
            android:src="@drawable/ic_indir" />

    </RelativeLayout>

红色方块 在图片中他们必须隐藏 The red squares

1 个答案:

答案 0 :(得分:1)

尝试使您的观点在XML 中不可见,并像这样更改您的Java代码

if( ekvarmı == true)
            {
                dosyaAdi.setVisibility(View.VISIBLE);
                atacResim.setVisibility(View.VISIBLE);
                ekButton.setVisibility(View.VISIBLE);

            }