import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public View getView(final int position, final View convertView, final ViewGroup parent) {
final DictionaryInfo dictionaryInfo = getItem(position);
final LinearLayout result = new LinearLayout(parent.getContext());
-
+ result.setOrientation(LinearLayout.VERTICAL);
+
+ final LinearLayout row = new LinearLayout(parent.getContext());
+ row.setOrientation(LinearLayout.HORIZONTAL);
+ result.addView(row);
+
final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
if ((!application.isDictionaryOnDevice(dictionaryInfo.uncompressedFilename) || updateAvailable) && downloadable != null) {
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
downloadButton.setLayoutParams(layoutParams);
- result.addView(downloadButton);
+ row.addView(downloadButton);
+ } else {
+ final ImageView checkMark = new ImageView(parent.getContext());
+ checkMark.setImageResource(android.R.drawable.checkbox_on_background);
+ row.addView(checkMark);
}
final TextView textView = new TextView(parent.getContext());
final String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename);
textView.setText(name);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
- result.addView(textView);
+ row.addView(textView);
// Add the information about each index.
+ final LinearLayout row2 = new LinearLayout(parent.getContext());
+ row2.setOrientation(LinearLayout.HORIZONTAL);
+ final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ row2.setLayoutParams(layoutParams);
+ result.addView(row2);
+ final StringBuilder builder = new StringBuilder();
for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) {
- final TextView indexView = new TextView(parent.getContext());
- indexView.setText(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount));
- result.addView(indexView);
+ if (builder.length() > 0) {
+ builder.append(" | ");
+ }
+ builder.append(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount));
}
-
+ final TextView indexView = new TextView(parent.getContext());
+ indexView.setText(builder.toString());
+ row2.addView(indexView);
+
+
// Because we have a Button inside a ListView row:
// http://groups.google.com/group/android-developers/browse_thread/thread/3d96af1530a7d62a?pli=1
result.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);