English 中文(简体)
Android - 适应器背后数据的令人信服的类型活动
原标题:Android - wizard type activity with adapter backed data

努力找到最佳办法,与安康一道解决下列问题。

我的数据来自内容提供者,其形式是一系列问题。 问题物体有一些文字和背书。 每个问题有4个答案,将回复到问题答复物体的其余服务器。

如同在某个时候要展示的问题一样(用户读懂问题,选择答案,然后打上新屏幕上下个问题的“顶点”,但我在登记内容观察员时,需要这样做(因为服务器上的问题可能发生变化,而服务器在内容提供者中更新)。 内容提供者储存的数据的变化应当随着情况的变化更新屏幕上的问题。

我猜测,我需要的是像简单的CursorAdaptor这样的东西,但认为不是一种清单,而是需要一种观点,即需要完全筛选出治疗者指出的一行。 我试图使我自己的适应者屈服,但 as不.地 next下。 这里是我的适应者。

public class QuestionAdapter implements Adapter {


public ArrayList<Question> questions = new ArrayList<Question>();
private Context context ;


public QuestionAdapter(ArrayList<Question> questions, Context context)
{
    this.questions.clear();
    this.questions.addAll(questions);
    this.context = context;
}

public void updateQuestions(ArrayList<Question> questions)
{
    questions.clear();
    questions.addAll(questions);
}

@Override
public int getCount() {
    return questions.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return questions.get(arg0);
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return Long.parseLong(questions.get(arg0).get_id());
}

@Override
public int getItemViewType(int arg0) {
    // TODO Auto-generated method stub
    return IGNORE_ITEM_VIEW_TYPE;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View questionView = inflater.inflate(R.layout.question, parent);
    return questionView;
}

@Override
public int getViewTypeCount() {
    return 1;
}

@Override
public boolean hasStableIds() {
    // TODO Auto-generated method stub
    return true;
}

@Override
public boolean isEmpty() {
    // TODO Auto-generated method stub
    return questions.isEmpty();
}

@Override
public void registerDataSetObserver(DataSetObserver arg0) {
    // TODO Auto-generated method stub

}

@Override
public void unregisterDataSetObserver(DataSetObserver arg0) {
    // TODO Auto-generated method stub

}
}

这里我的看法是xml。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/questionText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp"
    android:layout_weight="0.27"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ToggleButton
            android:id="@+id/passButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textOn="Pass"
            android:textOff="Pass" />

        <ToggleButton
            android:id="@+id/advisoryButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textOn="Advisory"
            android:textOff="Advisory" />

        <ToggleButton
            android:id="@+id/defectButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textOn="Defect" 
            android:textOff="Defect"/>

        <ToggleButton
            android:id="@+id/naButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textOn="N/A"
            android:textOff="N/A" />

    </TableRow>

</TableLayout>

<Button
    android:id="@+id/next"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:text="Next..." />

</LinearLayout>
最佳回答

这里是一位受过教育的怀疑者。

我不敢肯定,有其他观点很容易像一份名单一样受到约束,因此,我尝试并修改你的榜样,以编制一份清单。 第一, 如果你把清单本身填满——父母,并将儿童项目列入清单调查表Fill_ 父母,你将基本填写一份清单,显示只有一个孩子。 然后,你可以尝试:

www.un.org/spanish/ecosoc 甲型六氯环己烷

我认为,getCount(...)用于确定有多少数据流应当显示。 典型的情况是,我们要把这套内容计算在我们重新使用的阿雷拉主义者身上。 就你而言,我认为你只想在某个时候提出一个问题。

www.un.org/spanish/ecosoc 设立问题跟踪器

你们需要建立一个跟踪器,你现在要问你,你知道什么问题可以显示。 为此,你需要一个简单的<代码>int questionTracker变量,即每次回答/绕过/回答提问时,你都可以加油。

Modify getView(...) to show the correct Question

In the getView(...) call, you ll need to populate the screen with the correct question, which will be based on your tracker. Something like this

@Override public View getView(int position, View convertView, ViewGroup parent) 
{     
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);     
    View questionView = inflater.inflate(R.layout.question, parent);     

    //Get the next question
    Question currentQuestion = questions.get(questionTracker);

    //Fill the fields in the inflated layout with the data from the Question object
    TextView questionField = questionView.findViewById(R.id.questionText)
    questionField.setText(Question.question);

    return questionView; 
} 

www.un.org/spanish/ecosoc 更改问题:

欺骗性部分将迫使在你下游/下游/下台后重新思考。 尽管我从来没有这样做,但你可以人工打电话,因此我不相信。

问题回答

暂无回答




相关问题
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 ...

热门标签