2013-11-04 147 views
0

我是Android新手,正在嘗試創建一個類似於我所關注的在線教程的TODO列表。無法解析方法getText()

除todoText.setText(todoList.get(position).getText());「編譯正確。

使用該行,我收到以下錯誤消息:「can not resolve method getText()。」

這是負責在TODO清單顯示每個列表行一類的一部分:

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View rowView = inflater.inflate(R.layout.activity_main, parent, false); 
    TextView todoText = (TextView) rowView.findViewById(R.id.todoText); 
    todoText.setText(todoList.get(position).getText()); 
    return rowView; 
} 

我不知道如何解決這個問題。任何幫助將不勝感激。謝謝。

回答

0

很難說沒有看到todoList聲明,但機會是todoListStrings一個List(或別的東西,而是一個TextView)。如果是這樣的話,你可能只需要do.-

todoText.setText(todoList.get(position)); 
0

我不知道你的todoList內容的想法,但你可以做一個解決辦法,如果內容不是字符串使用.toString()

嘗試將代碼更改爲 -

todoText.setText(todoList.get(position).toString()); 

希望它有效。