package com.example.android.miwok; public class Word { private String mDefaultTranslation; private String mMiwokTranslation; public Word(String defaultTranslation, String miwokTranslation){ mDefaultTranslation = defaultTranslation; mMiwokTranslation = miwokTranslation; } public String getDefaultTranslation(){ return mDefaultTranslation; } public String getMiwokTranslation(){ return mMiwokTranslation; } }
ArrayAdapter
https://developer.android.com/reference/android/widget/ArrayAdapter.html?utm_source=udacity&utm_medium=course&utm_campaign=android_basics
import androis.os.Bundle; import android.support.v7.app.AppCompactActivity; import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; package com.example.android.miwok; public class NumbersActivity extends AppCompactActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_numbers); // Create on array of words ArrayList<Word> words = new ArrayList<Word>(); words.add(new Word("one", "lutti")); words.add(new Word("two", "otiiko")); words.add(new Word("three", "tolookosu")); words.add(new Word("four", "oyyisa")); words.add(new Word("five", "massokka")); words.add(new Word("six", "temmokka")); words.add(new Word("seven", "kenekaku")); words.add(new Word("eight", "kawinta")); words.add(new Word("nine", "wo'e")); words.add(new Word("ten", "na'aacha")); ArrayAdapter<Word> itemsAdapter = new ArrayAdapter<Word>(this, android.R.layout.list_item, words); GridView listView = (GridView) findViewById(R.id.list); listView.setAdapter(itemsAdapter); } }