安卓中的界面

发布于 2024-12-11 14:32:55 字数 173 浏览 0 评论 0原文

我在 android 中编写了一个包含图像和视频视图的表格布局。

我想在 android 中编写一个界面,它将在不干扰我的布局的情况下获取图像以及数据和视频。

该数据可以采用任何形式、来自任何来源,并且必须通过接口提供给布局。

我应该如何为我在android中开发的布局编写程序界面?

I have written a table layout in android that contains image and video view.

I want to write an interface in android which will take the images as well as data and videos without disturbing my layout.

This data can come in any form and from any source and has to be supplied to the layout through the interface.

How should I write a program interface for the layout that I have developed in android?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨巷深深 2024-12-18 14:32:55

下面是Android中使用的CallBack接口的示例代码

public class BackGroundProcess
    {
    private RequestCallback mCallback;
    public BackGroundPrecess(RequestCallback ObjRequestCallback)
    {
    mCallback=ObjRequestCallback;
    }

    public void doBackgroundProcess()
    {
    /// perform action here
     onProcessComplete();

    }
    private void onProcessComplete(){
    mCallback.requestDidLoad(response);
    }
    }



    // activity class
    public class main_activity extends Activity{

    private void post_message()
        {
    BackGroundProcess obj=new BackGroundProcess(new MSRequestCallback());
    obj.doBackgroundProcess();

    }

    // Interface
    private class MSRequestCallback extends RequestCallback {

           public void requestDidFail(String page) {

                mHandler.post(mUpdate);  
           }

    }

    final Handler mHandler= new Handler();

       final Runnable mUpdate = new Runnable() {
           public void run() {
              // update the UI
           }
       };
    }

Below is the sample code for CallBack Interface used in Android

public class BackGroundProcess
    {
    private RequestCallback mCallback;
    public BackGroundPrecess(RequestCallback ObjRequestCallback)
    {
    mCallback=ObjRequestCallback;
    }

    public void doBackgroundProcess()
    {
    /// perform action here
     onProcessComplete();

    }
    private void onProcessComplete(){
    mCallback.requestDidLoad(response);
    }
    }



    // activity class
    public class main_activity extends Activity{

    private void post_message()
        {
    BackGroundProcess obj=new BackGroundProcess(new MSRequestCallback());
    obj.doBackgroundProcess();

    }

    // Interface
    private class MSRequestCallback extends RequestCallback {

           public void requestDidFail(String page) {

                mHandler.post(mUpdate);  
           }

    }

    final Handler mHandler= new Handler();

       final Runnable mUpdate = new Runnable() {
           public void run() {
              // update the UI
           }
       };
    }
廻憶裏菂餘溫 2024-12-18 14:32:55

首先你需要两个课程。

  1. 第一个类将表现为Activity,您需要在其中显示布局并实现接口或抽象类。
  2. 第二个类将负责使用 AsyncTask 它将把接口对象作为构造函数的输入,当此类中的任务完成时,它将通过传递数据调用第一类传递的接口对象的方法来更新第一类。

接口应该在Activity类中定义和实现,其方法将更新第一个类的UI。

如果您需要一些代码帮助,请告诉我

First you need two classes.

  1. First class will behave as Activity in which You need to display the layout and implemented the interface or abstract class.
  2. Second class will be responsible for fetching the data in background using AsyncTask which will take object of interface as input in constructor and when task in this class in completed then it will update first class by calling the method of object of interface passed by first class by passing data.

Interface should be defined and implemented in Activity class and method of which will update the UI of first class.

Please let me know if u need some code help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文