android - 如何在android中使用异步任务在自定义布局中一个接一个地显示项目

标签 android class asynchronous background-process

我在代码中创建一个布局使用 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/

相关文章:

c# - 任务的延续(由 async/await 构建)在 WPF 应用程序的主线程上运行,但在控制台应用程序的子线程上运行

android - 我应该在应用程序还活着的时候维护一个连接的 GoogleApiClient 吗?

android - 安卓NDK |如何确定 NDK 9c 支持哪种 C++ 标准

android - 通知不会在 Android 10 中取消

javascript - 异步 JavaScript : Proper way to make loops?

javascript - ngRouter 到 ui-router

android - 在 tab 键请求上关注 spinner-Android

JavaScript:如何将单个全局对象传递给一组类?

c++ - 如何在不使用类名作为作用域的情况下获取类中成员函数的地址?

java - 我应该如何在 Java 中初始化一个复杂的实例变量?