Java 从OnItemClick的列表适配器获取数据时遇到问题

Java 从OnItemClick的列表适配器获取数据时遇到问题,java,android,string,android-listview,listadapter,Java,Android,String,Android Listview,Listadapter,当我的listadapter设置为我的listview时,我在获取数据方面遇到了问题。我试图在onItemClick中获取这些数据,这样我就可以将其放入我的intent extra中,供我的其他活动获取 问题 目前,我已经创建了空字符串变量,然后在适配器中通过模型中的方法为字符串分配所需的文本。然而,我的问题是,正在被拉的文本不是正确的文本的位置,onitemclick被要求 这里有一些代码 XMLParseActivity 我通过从模型中的一些简单方法获取数据来获得值,从而解决了这个问题 为什

当我的listadapter设置为我的listview时,我在获取数据方面遇到了问题。我试图在onItemClick中获取这些数据,这样我就可以将其放入我的intent extra中,供我的其他活动获取

问题 目前,我已经创建了空字符串变量,然后在适配器中通过模型中的方法为字符串分配所需的文本。然而,我的问题是,正在被拉的文本不是正确的文本的位置,onitemclick被要求

这里有一些代码

XMLParseActivity
我通过从模型中的一些简单方法获取数据来获得值,从而解决了这个问题

为什么要将数据传递到适配器?如果已经定义了模型,那么就可以直接从主类中获取数据。如果我误解了这个问题,请纠正我。@Mike2013 2013是的,我想你是对的,我想我只是不确定获取数据的最佳方法。现在,正如您在适配器代码中看到的,我的IssueFeed和issueFeedList已经定义,因此我能够使用模型中的方法来提取数据。你能推荐一个替代方案吗?
public class XMLParseActivity extends Activity implements AdapterView.OnItemClickListener {

 private ListView mIssueListView;
 private IssueParser mIssueParser;
 private List<IssueFeed> mIssueList;
 private IssueAdapter mIssueAdapter;

 private String result_connectedtype = "";
 private String result_symptom = "";
 private String result_problem = "";
 private String result_solution = "";
 private String result_comments = "";
public class IssueAdapter extends ArrayAdapter<IssueFeed> {
    public List<IssueFeed> issueFeedList;

    public IssueAdapter(Context context, int textViewResourceId, List<IssueFeed> issueFeedList) {
        super(context, textViewResourceId, issueFeedList);
        this.issueFeedList = issueFeedList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        IssueHolder issueHolder = null;
        if (convertView == null) {
            view = View.inflate(XMLParseActivity.this, R.layout.issue_list_item, null);
            issueHolder = new IssueHolder();
            issueHolder.issueConnectedType = (TextView) view.findViewById(R.id.result_connected_type);
            issueHolder.issueSymptomView = (TextView) view.findViewById(R.id.result_symptom);
            view.setTag(issueHolder);
        } else {
            issueHolder = (IssueHolder) view.getTag();
        }
        IssueFeed issueFeed = issueFeedList.get(position);
        issueHolder.issueConnectedType.setText(issueFeed.getConnected_type());
        issueHolder.issueSymptomView.setText(issueFeed.getSymptom());

        //THE DATA I WANT TO USE IN MY INTENT
        result_solution = issueFeed.getSolution();
        result_comments = issueFeed.getComments();
        result_connectedtype = issueFeed.getConnected_type();
        result_problem = issueFeed.getProblem();
        result_symptom = issueFeed.getSymptom();

        return view;
    }
}

static class IssueHolder {
    public TextView issueSymptomView;
    public TextView issueConnectedType;
}

@Override
public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {

    //Put the strings in intent extra
    Intent intent = new Intent(this, SpecificIssueActivity.class);
    intent.putExtra("symptom", result_symptom);
    intent.putExtra("problem", result_problem);
    intent.putExtra("solution", result_solution);
    intent.putExtra("comments", result_comments);
    intent.putExtra("connectedtype", result_connectedtype);
    startActivity(intent);
}
public class DoLocalParse extends AsyncTask<String, Void, List<IssueFeed>> {
    ProgressDialog prog;
    String jsonStr = null;
    Handler innerHandler;

    @Override
    protected void onPreExecute() {
        prog = new ProgressDialog(XMLParseActivity.this);
        prog.setMessage("Loading....");
        prog.show();
    }

    @Override
    protected List<IssueFeed> doInBackground(String... params) {
        mIssueParser = new IssueParser(null);
        mIssueList = mIssueParser.parseLocally(params[0]);

        return mIssueList;
    }

    @Override
    protected void onPostExecute(List<IssueFeed> result) {
        prog.dismiss();
        runOnUiThread(new Runnable() {

            @Override
            public void run() {
                mIssueAdapter = new IssueAdapter(XMLParseActivity.this, R.layout.issue_list_item,
                        mIssueList);
                int count = mIssueAdapter.getCount();
                if (count != 0 && mIssueAdapter != null) {
                    mIssueListView.setAdapter(mIssueAdapter);
                }
            }
        });
    }
}
public class IssueFeed implements Serializable {

private String connected_type;
private String symptom;
private String problem; 
private String solution; 
private String comments; 

public IssueFeed() {
}

public IssueFeed(String connected_type, String symptom, String problem, String solution, String comments) {
    this.connected_type = connected_type;
    this.symptom = symptom;
    this.problem = problem;
    this.solution = solution;
    this.comments = comments;
}

public String getConnected_type() {
    return connected_type;
}

public String getSymptom() {
    return symptom;
}

public String getProblem() {
    return problem;
}

public String getSolution() {
    return solution;
}

public String getComments() {
    return comments;
}

public void setConnected_type(String connected_type) {
    this.connected_type = connected_type;
}

public void setSymptom(String symptom) {
    this.symptom = symptom;
}

public void setProblem(String problem) {
    this.problem = problem;
}

public void setSolution(String solution) {
    this.solution = solution;
}

public void setComments(String comments) {
    this.comments = comments;
}
}