English 中文(简体)
入学活动情况
原标题:Accessing activity s state in CursorAdapter subclass

I m 撰写一份相当复杂的<代码>ListView,其中(除其他事项外)要求在每个清单项目上编排意见。

为了让我完全控制每个项目的意见约束方式,我以这种方式分类如下:

public class MyAdapter extends CursorAdapter {

    public final LayoutInflater mInflater;

    public MyAdapter(Context context, Cursor c) {
        super(context, c);
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        final ToggleButton tButton = (ToggleButton) view.findViewById(R.id.tbutton);
        tButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // start activity based on a pending intent
            }
        });     

    }
}

问题是,我的<代码>ToggleButton点击的听众应根据一种预定意向开始活动。 在利用这一定制适应器的活动中,即时出现尚未达到的意图。

I mnow I could have used a SimpleCursorAdapter in the main Actective with a ViewBinder 因此,只有从主要<代号>/代码>上发布意向。 But SimpleCursorAdapter 由于我没有直线绘制一栏图来表达看法,这并不完全正确。

然而,我在此提出的备选案文建议是使用主要<代码>。 活动从 cur子流出的数据。 我认为,必须有更好的办法来设计申请。

最佳回答

我从AAP Demos(具体来说是 高效用Adapter)中抽出一个 cu子,作为我活动的内在类别。

这避免了在主要活动之外通过尚未达到的意图。

资料来源:

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签