View.Invisible - изображения остаются на экране
Я пытаюсь установить видимость моего изображения, кнопки и текста. Но они все еще там, когда я запускаю программу. Я попытался View.GONE, но это просто удалить все текстовое представление, изображение и кнопку. Но я просто хочу спрятаться, а потом показать.
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);
А другая активность вызывает этот метод для добавления "еквар"
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>
Красные квадраты На картинке они должны спрятаться
1 ответ
Решение
Постарайтесь сделать ваши представления невидимыми в XML и измените свой Java-код следующим образом
if( ekvarmı == true)
{
dosyaAdi.setVisibility(View.VISIBLE);
atacResim.setVisibility(View.VISIBLE);
ekButton.setVisibility(View.VISIBLE);
}