如何延迟在android studio中显示元素我有2个ImageView
<ImageView
android:id="@+id/a_letter"
android:background="#00000000"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="100dp"
app:srcCompat="@drawable/a_letter"
/>
和
<ImageView
android:id="@+id/b_letter"
android:background="#00000000"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="100dp"
app:srcCompat="@drawable/b_letter"
/>
如果在打开布局时首先加载ImageView
a_letter
加载ImageView
b_letter
,请在<?php
if(mysqli_num_rows($check_ip) > 0 )
{
?>
<script type="text/javascript">
$(document).ready(function()
{
$("#myModal").modal('show');
});
</script>
<?php
}
?>
之前延迟3秒显示<div id="myModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Welcome back! Here's our recommended speakers for you.</h4>
</div>
<div class="modal-body">
<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
$check_ip = mysqli_query($conn, "SELECT ip_address FROM reservations WHERE ip_address = '$user_ip'");
$history_data = mysqli_query($conn, "SELECT * FROM reservations WHERE ip_address = '$user_ip'");
$row = mysqli_fetch_array($history_data);
$topic = $row['topic'];
$ip_address = $row['ip_address'];
$select_speakers = mysqli_query($conn, "SELECT * FROM speakers WHERE speaker_specialization1 = '$topic' OR speaker_specialization2 = '$topic' OR speaker_specialization3 = '$topic' ORDER BY speaker_reservedcount DESC LIMIT 3");
while($row = mysqli_fetch_array($select_speakers))
{
echo '
<a href="speakerProfile.php?id='.$row["id"].'">
<div class=" col-sm-4 ">
<div class="thumbnail"><img class="speakers-image" src="img/'.$row["speaker_image"].'" style="height:150px; min-width:100%;"/>
<div class="caption" style="max-height:270px; min-width:100%" >
<center>
<h3 class="speakers-name" style="font-weight:bold; margin: 2px 10px -6px 10px;">'.$row["speaker_fullname"].'</h3>
<hr>
<div class="speaker-topics" style="margin-top:-20px;">
<p style="text-transform: capitalize;">'.$row["speaker_specialization1"].'</p>
</div>
<div class="speaker-topics">
<p style="text-transform: capitalize;">'.$row["speaker_specialization2"].'</p>
</div>
<div class="speaker-topics">
<p style="text-transform: capitalize;">'.$row["speaker_specialization3"].'</p>
</div>
<hr>
<p class="speakers-name" style="margin:-10px 0px 5 px 0px;">Reserved Count: '.$row["speaker_reservedcount"].'</p>
</center>
</div>
</div>
</div>
</a>
';
}
?>
</div>
</div>
</div>
</div>
的 ID ?
这是一个转变吗?
答案 0 :(得分:1)
首先通过添加:
使图像视图在xml中消失<ImageView
android:id="@+id/b_letter"
android:background="#00000000"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="100dp"
app:srcCompat="@drawable/b_letter"
android:visibility="gone"/>
然后使用Handler
:
ImageView bImageView = (ImageView) findViewById(R.id.b_letter);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
bImageView.setVisibility(View.VISIBLE);
}
}, 3000);