请建议我如何传递图片视图,因为我尝试通过并尝试了大量转换,但失败了。
MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// here i want to take image and pass it on via loadphoto
loadPhoto(R.drawable.ic_launcher, 400, 100);
}
private void loadPhoto(ImageView imageView, int width, int height) {
ImageView tempImageView = imageView;
AlertDialog.Builder imageDialog = new AlertDialog.Builder(this);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.activity_main,
(ViewGroup) findViewById(R.id.layout_root));
ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
image.setImageDrawable(tempImageView.getDrawable());
imageDialog.setView(layout);
imageDialog.setPositiveButton("OK", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
imageDialog.create();
imageDialog.show();
}
}
actvity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="@+id/fullimage"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ImageView>
<TextView
android:id="@+id/custom_fullimage_placename"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF" >
</TextView>
</LinearLayout>
答案 0 :(得分:0)
每次间隔后显示图像视图,因为我想从服务器上显示广告 这意味着您应该使用(需要)Timer任务(简单)或调度线程使其可运行。 在
new Runnable() { // Your work here: // Load the image }
同样通知:更新图片在UI线程上执行。 对不起,你的问题可能太过分了。
loadPhoto(Integer imageSourceID, Context mContext)
并使用getResource()我希望这些会对你有所帮助 4.