X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryActivity.java;h=84238e9f3fafd110eb5a83c7ca7bf7f590490555;hb=da55b878cfd6c5f7b042c5ef0d0ce7a5d35431b7;hp=f526cb9eebbd46b0d09cde37c042a8459b441a28;hpb=da34b5e456ccb3d3be49c6b09ae5047fbe833b90;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index f526cb9..84238e9 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -64,8 +64,10 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.webkit.WebView; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.BaseAdapter; @@ -83,6 +85,7 @@ import android.widget.Toast; import com.hughes.android.dictionary.DictionaryInfo.IndexInfo; import com.hughes.android.dictionary.engine.Dictionary; import com.hughes.android.dictionary.engine.EntrySource; +import com.hughes.android.dictionary.engine.HtmlEntry; import com.hughes.android.dictionary.engine.Index; import com.hughes.android.dictionary.engine.Index.IndexEntry; import com.hughes.android.dictionary.engine.PairEntry; @@ -929,6 +932,9 @@ public class DictionaryActivity extends ListActivity { // -------------------------------------------------------------------------- // IndexAdapter // -------------------------------------------------------------------------- + + static ViewGroup.LayoutParams WEIGHT_1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT, 1.0f); + static ViewGroup.LayoutParams WEIGHT_0 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0f); final class IndexAdapter extends BaseAdapter { @@ -977,6 +983,8 @@ public class DictionaryActivity extends ListActivity { return getView(position, (PairEntry.Row) row, parent, result); } else if (row instanceof TokenRow) { return getView((TokenRow) row, parent, result); + } else if (row instanceof HtmlEntry.Row) { + return getView((HtmlEntry.Row) row, parent, result); } else { throw new IllegalArgumentException("Unsupported Row type: " + row.getClass()); } @@ -1071,7 +1079,39 @@ public class DictionaryActivity extends ListActivity { return result; } + + private TableLayout getView(HtmlEntry.Row row, ViewGroup parent, final TableLayout result) { + final Context context = parent.getContext(); + + final HtmlEntry htmlEntry = row.getEntry(); + + //final TableRow tableRow = new TableRow(context); + final LinearLayout tableRow = new LinearLayout(context); + result.addView(tableRow); + + // Text. + final TextView textView = new TextView(context); + textView.setText(htmlEntry.title); + textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f)); + tableRow.addView(textView); + + // Button. + final Button button = new Button(context); + button.setText("open"); + button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0.0f)); + tableRow.addView(button); + + button.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(HtmlDisplayActivity.getHtmlIntent(String.format("%s", htmlEntry.html))); + } + }); + + return result; + } + private TableLayout getView(TokenRow row, ViewGroup parent, final TableLayout result) { final Context context = parent.getContext(); final TextView textView = new TextView(context);