0

我试图设置我的 imageview 、 button 和 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>

红色方块在图片上他们必须隐藏 红色方块

4

1 回答 1

1

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

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

            }
于 2012-04-28T21:15:45.970 回答