2016-06-23 18 views
0

リストに2つの配列を入力する必要があるため、ベースアダプタから拡張されたカスタムリストアダプタを作成しました。コードは次のとおりです。Android Studioがリストアダプタでメソッドを解決できない

public class OweListAdaptor extends BaseAdapter { 
String[] descriptionArray, valueArray; 
Context context; 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    LayoutInflater inflater = LayoutInflater.from(context); 
    View oweRow = inflater.inflate(R.layout.oweitem, parent, false); 

    TextView description = (TextView) oweRow.findViewById(R.id.descText); 
    TextView value = (TextView) oweRow.findViewById(R.id.valText); 
    description.setText(descriptionArray[position]); 
    value.setText(valueArray[position]); 

    return oweRow; 
} 

public OweListAdaptor(String[] description, String[] value) { 
    this.descriptionArray = description; 
    this.valueArray = value; 
} 

public void updateValues(String[] newList){ 
    for (int i=0; i< newList.length; i++){ 
     valueArray[i] = newList[i]; 
    } 
    this.notifyDataSetChanged(); 
} 

public void updateDescriptions(String[] newList){ 
    for (int i=0; i< newList.length; i++){ 
     descriptionArray[i] = newList[i]; 
    } 
    this.notifyDataSetChanged(); 
} 

最後の2つのメソッド、updateValuesおよびupdateDescriptionsは、MainActivityから呼び出すことはできません。私はそれらを呼び出すしようとすると、Androidのメーカーはそれを言う

方法「updateValuesは(java.lang.Stringで[]」)

それを呼び出すために、私は単にMainActivityで、次の使用しています解決できません。

public class MainActivity extends AppCompatActivity { 
String[] descriptionList, valueList; 
OweDBManager DB; 
ListAdapter oweAdapter; 

public void updateLists(){ 
    descriptionList = DB.DBtoArray("desc"); 
    valueList = DB.DBtoArray("value"); 
    oweAdapter.updateValues(valueList); 
} 

DBマネージャとリストアダプタは、onStartで初期化されます。なぜこのエラーが発生するのですか?

答えて

0

あなたのMainActivityがListAdapter oweAdapterからOweListAdaptor oweAdapterに変更され、動作します。

0

カスタムアダプタを使用しているので、ListAdapterの代わりにOweListAdapterを使用します。

関連する問題