Skip to content
Browse files

Display tense and politeness level above the conjugation

  • Loading branch information...
1 parent 2c25867 commit ebfe9faf250d567a36cb1a98fa148e8ff94ca240 @dbravender committed May 4, 2011
View
40 android/res/layout/simple_expandable_list_item_2.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="2dip"
+ android:paddingBottom="2dip"
+ android:mode="twoLine"
+>
+
+ <TextView android:id="@+id/text1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
+ <TextView android:id="@+id/text2"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/text1"
+ android:layout_alignLeft="@+id/text1"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ />
+
+</TwoLineListItem>
View
46 android/src/us/bravender/android/dongsa/Dongsa.java
@@ -7,24 +7,23 @@
import android.widget.ListView;
import android.widget.EditText;
import android.widget.TextView;
+import android.widget.SimpleAdapter;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.text.Editable;
import android.content.Context;
import android.content.res.Configuration;
import java.util.ArrayList;
-import android.widget.ArrayAdapter;
+import java.util.HashMap;
public class Dongsa extends Activity {
- private ArrayList<String> lnames;
+ private ArrayList<HashMap<String,String>> conjugations = new ArrayList<HashMap<String,String>>();
private ListView list;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- this.lnames = new ArrayList<String>();
-
final WebView engine = new WebView(this);
engine.getSettings().setJavaScriptEnabled(true);
engine.addJavascriptInterface(new JavaScriptInterface(this), "Android");
@@ -38,27 +37,36 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
});
this.list = (ListView) findViewById(R.id.listview);
- this.list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, this.lnames));
+ this.list.setAdapter(new SimpleAdapter(
+ this,
+ this.conjugations,
+ R.layout.simple_expandable_list_item_2,
+ new String[] { "conjugation_name", "conjugated" },
+ new int[] { R.id.text1, R.id.text2 }
+ ));
edittext.setText("\ud558\ub2e4");
engine.loadUrl("file:///android_asset/html/android.html");
}
public void clearList() {
- synchronized (this.lnames) {
- this.lnames.clear();
+ synchronized (this.conjugations) {
+ this.conjugations.clear();
}
}
- public void add(String item) {
- synchronized (this.lnames) {
- this.lnames.add(item);
+ public void add(String conjugation_name, String conjugated) {
+ synchronized (this.conjugations) {
+ HashMap<String,String> item = new HashMap<String,String>();
+ item.put("conjugation_name", conjugation_name);
+ item.put("conjugated", conjugated);
+ this.conjugations.add(item);
}
}
public void displayList() {
- synchronized (this.lnames) {
- final ArrayAdapter adapter = (ArrayAdapter)this.list.getAdapter();
+ synchronized (this.conjugations) {
+ final SimpleAdapter adapter = (SimpleAdapter)this.list.getAdapter();
this.list.post(new Runnable() {
public void run() {
adapter.notifyDataSetChanged();
@@ -86,12 +94,22 @@ public void clearList() {
((Dongsa)mContext).clearList();
}
- public void add(String item) {
- ((Dongsa)mContext).add(item);
+ public void add(String conjugation_name, String conjugated) {
+ ((Dongsa)mContext).add(conjugation_name, conjugated);
}
public void displayList() {
((Dongsa)mContext).displayList();
}
}
+
+ public class ConjugationEntry {
+ public String conjugated;
+ public String conjugation_name;
+
+ public ConjugationEntry(String conjugation_name, String conjugated) {
+ this.conjugated = conjugated;
+ this.conjugation_name = conjugation_name;
+ }
+ }
}
View
2 html/android.html
@@ -22,7 +22,7 @@
Android.clearList();
conjugator.each_conjugation(infinitive, regular, function(r) {
//TODO: need to handle verbs that have regular and irregulars
- Android.add(r.conjugated);
+ Android.add(r.conjugation_name, r.conjugated);
});
Android.displayList();
}

0 comments on commit ebfe9fa

Please sign in to comment.
Something went wrong with that request. Please try again.