我在代码中创建一个布局使用 web 服务检索所有消息字符串和图像所有检索后台进程中的数据显示数据总计所有 View 显示一次,
我的 Intent 是在显示自定义布局之后获取一个消息字符串和一个图像接下来获取另一个(第二个)消息字符串和图像然后显示添加布局这个功能一个一个地运行显示消息和图像
xml文件:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:background="@android:color/white"
android:layout_height="fill_parent">
<ScrollView android:id="@+id/scrollView1"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ScrollView>
</FrameLayout>
代码文件:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView1);
LinearLayout topLinearLayout = new LinearLayout(this);
topLinearLayout.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < 15; i++){
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
ImageView imageView = new ImageView (this);
TextView textView = new TextView (this);
imageView.setImageResource(R.drawable.image);
textView.setText("Text View #" + i);
linearLayout.addView(imageView);
linearLayout.addView(textView);
topLinearLayout.addView(linearLayout);
}
scrollView.addView(topLinearLayout);
}
如何在自定义布局中动态地一一显示图像和消息 请转发一些解决方案提前谢谢
最佳答案
using asynronous task in u r application update to ui
http://developer.android.com/reference/android/os/AsyncTask.html
关于android - 如何在android中使用异步任务在自定义布局中一个接一个地显示项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5622594/