use of android.widget.SimpleAdapter in project android_frameworks_base by ParanoidAndroid.
the class HwTests method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String path = intent.getStringExtra("com.android.test.hwui.Path");
if (path == null) {
path = "";
}
setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
getListView().setTextFilterEnabled(true);
}
use of android.widget.SimpleAdapter in project GT by Tencent.
the class GTDemoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gt_demo);
showImg = (Button) findViewById(R.id.showimg);
showImg.setOnClickListener(showImage);
gridview = (GridView) findViewById(R.id.gridview);
saImageItems = new SimpleAdapter(getApplicationContext(), lstImageItem, R.layout.gt_gridview_item, new String[] { "img" }, new int[] { R.id.ItemImage });
}
use of android.widget.SimpleAdapter in project Anki-Android by Ramblurr.
the class DeckPicker method onCreate.
// ----------------------------------------------------------------------------
// ANDROID METHODS
// ----------------------------------------------------------------------------
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) throws SQLException {
Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate");
Intent intent = getIntent();
if (!isTaskRoot()) {
Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate: Detected multiple instance of this activity, closing it and return to root activity");
Intent reloadIntent = new Intent(DeckPicker.this, DeckPicker.class);
reloadIntent.setAction(Intent.ACTION_MAIN);
if (intent != null && intent.getExtras() != null) {
reloadIntent.putExtras(intent.getExtras());
}
if (intent != null && intent.getData() != null) {
reloadIntent.setData(intent.getData());
}
reloadIntent.addCategory(Intent.CATEGORY_LAUNCHER);
reloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
finish();
startActivityIfNeeded(reloadIntent, 0);
}
if (intent.getData() != null) {
mImportPath = getIntent().getData().getEncodedPath();
}
// need to start this here in order to avoid showing deckpicker before splashscreen
if (AnkiDroidApp.colIsOpen()) {
setTitle(getResources().getString(R.string.app_name));
} else {
setTitle("");
mOpenCollectionHandler.onPreExecute();
}
Themes.applyTheme(this);
super.onCreate(savedInstanceState);
// mStartedByBigWidget = intent.getIntExtra(EXTRA_START, EXTRA_START_NOTHING);
SharedPreferences preferences = restorePreferences();
// activate broadcast messages if first start of a day
if (mLastTimeOpened < UIUtils.getDayStart()) {
preferences.edit().putBoolean("showBroadcastMessageToday", true).commit();
}
preferences.edit().putLong("lastTimeOpened", System.currentTimeMillis()).commit();
// if (intent != null && intent.hasExtra(EXTRA_DECK_ID)) {
// openStudyOptions(intent.getLongExtra(EXTRA_DECK_ID, 1));
// }
BroadcastMessages.checkForNewMessages(this);
View mainView = getLayoutInflater().inflate(R.layout.deck_picker, null);
setContentView(mainView);
// check, if tablet layout
View studyoptionsFrame = findViewById(R.id.studyoptions_fragment);
mFragmented = studyoptionsFrame != null && studyoptionsFrame.getVisibility() == View.VISIBLE;
Themes.setContentStyle(mFragmented ? mainView : mainView.findViewById(R.id.deckpicker_view), Themes.CALLER_DECKPICKER);
registerExternalStorageListener();
if (!mFragmented) {
mAddButton = (ImageButton) findViewById(R.id.deckpicker_add);
mAddButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
addNote();
}
});
mCardsButton = (ImageButton) findViewById(R.id.deckpicker_card_browser);
mCardsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openCardBrowser();
}
});
mStatsButton = (ImageButton) findViewById(R.id.statistics_all_button);
mStatsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DIALOG_SELECT_STATISTICS_TYPE);
}
});
mSyncButton = (ImageButton) findViewById(R.id.sync_all_button);
mSyncButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
sync();
}
});
}
mInvalidateMenu = false;
mDeckList = new ArrayList<HashMap<String, String>>();
mDeckListView = (ListView) findViewById(R.id.files);
mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item, new String[] { "name", "new", "lrn", // "complMat", "complAll",
"rev", "sep", "dyn" }, new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn, // R.id.deckpicker_bar_mat, R.id.deckpicker_bar_all,
R.id.deckpicker_rev, R.id.deckpicker_deck, R.id.DeckPickerName });
mDeckListAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data, String text) {
if (view.getId() == R.id.deckpicker_deck) {
if (text.equals("top")) {
view.setBackgroundResource(R.drawable.white_deckpicker_top);
return true;
} else if (text.equals("bot")) {
view.setBackgroundResource(R.drawable.white_deckpicker_bottom);
return true;
} else if (text.equals("ful")) {
view.setBackgroundResource(R.drawable.white_deckpicker_full);
return true;
} else if (text.equals("cen")) {
view.setBackgroundResource(R.drawable.white_deckpicker_center);
return true;
}
} else if (view.getId() == R.id.DeckPickerName) {
if (text.equals("d0")) {
((TextView) view).setTextColor(getResources().getColor(R.color.non_dyn_deck));
return true;
} else if (text.equals("d1")) {
((TextView) view).setTextColor(getResources().getColor(R.color.dyn_deck));
return true;
}
}
// return false;
return false;
}
});
mDeckListView.setOnItemClickListener(mDeckSelHandler);
mDeckListView.setAdapter(mDeckListAdapter);
if (mFragmented) {
mDeckListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
registerForContextMenu(mDeckListView);
showStartupScreensAndDialogs(preferences, 0);
if (mSwipeEnabled) {
gestureDetector = new GestureDetector(new MyGestureDetector());
mDeckListView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
});
}
}
use of android.widget.SimpleAdapter in project Anki-Android by Ramblurr.
the class Feedback method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Themes.applyTheme(this);
super.onCreate(savedInstanceState);
Resources res = getResources();
Context context = getBaseContext();
SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context);
mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK);
mNonce = UUID.randomUUID().getMostSignificantBits();
mFeedbackUrl = res.getString(R.string.feedback_post_url);
mErrorUrl = res.getString(R.string.error_post_url);
mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mPostingFeedback = false;
initAllAlertDialogs();
getErrorFiles();
Intent i = getIntent();
mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK);
if (!mAllowFeedback) {
if (mReportErrorMode.equals(REPORT_ALWAYS)) {
// Always report
try {
String feedback = "Automatically sent";
Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true }));
if (mErrorReports.size() > 0) {
mPostingFeedback = true;
}
if (feedback.length() > 0) {
mPostingFeedback = true;
}
} catch (Exception e) {
Log.e(AnkiDroidApp.TAG, e.toString());
}
finish();
if (AnkiDroidApp.SDK_VERSION > 4) {
ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE);
}
return;
} else if (mReportErrorMode.equals(REPORT_NEVER)) {
// Never report
deleteFiles(false, false);
finish();
if (AnkiDroidApp.SDK_VERSION > 4) {
ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE);
}
return;
}
}
View mainView = getLayoutInflater().inflate(R.layout.feedback, null);
setContentView(mainView);
Themes.setWallpaper(mainView);
Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer));
Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList));
Button btnSend = (Button) findViewById(R.id.btnFeedbackSend);
Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest);
Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll);
mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText);
mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList);
mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status });
mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object arg1, String text) {
switch(view.getId()) {
case R.id.error_item_progress:
if (text.equals(STATE_UPLOADING)) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
return true;
case R.id.error_item_status:
if (text.length() == 0) {
view.setVisibility(View.GONE);
return true;
} else {
view.setVisibility(View.VISIBLE);
return false;
}
}
return false;
}
});
btnClearAll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
deleteFiles(false, false);
refreshErrorListView();
refreshInterface();
}
});
mLvErrorList.setAdapter(mErrorAdapter);
btnSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!mPostingFeedback) {
String feedback = mEtFeedbackText.getText().toString();
Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false }));
if (mErrorReports.size() > 0) {
mPostingFeedback = true;
}
if (feedback.length() > 0) {
mPostingFeedback = true;
}
refreshInterface();
}
}
});
btnKeepLatest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
deleteFiles(false, true);
refreshErrorListView();
refreshInterface();
}
});
refreshInterface();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
use of android.widget.SimpleAdapter in project Anki-Android by Ramblurr.
the class CardEditor method createDialogIntentInformation.
private StyledDialog createDialogIntentInformation(Builder builder, Resources res) {
builder.setTitle(res.getString(R.string.intent_add_saved_information));
ListView listView = new ListView(this);
mIntentInformationAdapter = new SimpleAdapter(this, mIntentInformation, R.layout.card_item, new String[] { "source", "target", "id" }, new int[] { R.id.card_sfld, R.id.card_tmpl, R.id.card_item });
listView.setAdapter(mIntentInformationAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(CardEditor.this, CardEditor.class);
intent.putExtra(EXTRA_CALLER, CALLER_CARDEDITOR_INTENT_ADD);
HashMap<String, String> map = mIntentInformation.get(position);
intent.putExtra(EXTRA_CONTENTS, map.get("fields"));
intent.putExtra(EXTRA_ID, map.get("id"));
startActivityForResult(intent, REQUEST_INTENT_ADD);
if (AnkiDroidApp.SDK_VERSION > 4) {
ActivityTransitionAnimation.slide(CardEditor.this, ActivityTransitionAnimation.FADE);
}
mIntentInformationDialog.dismiss();
}
});
mCardItemBackground = Themes.getCardBrowserBackground()[0];
mIntentInformationAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object arg1, String text) {
if (view.getId() == R.id.card_item) {
view.setBackgroundResource(mCardItemBackground);
return true;
}
return false;
}
});
listView.setBackgroundColor(android.R.attr.colorBackground);
listView.setDrawSelectorOnTop(true);
listView.setFastScrollEnabled(true);
Themes.setContentStyle(listView, Themes.CALLER_CARDEDITOR_INTENTDIALOG);
builder.setView(listView, false, true);
builder.setCancelable(true);
builder.setPositiveButton(res.getString(R.string.intent_add_clear_all), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
MetaDB.resetIntentInformation(CardEditor.this);
mIntentInformation.clear();
dialog.dismiss();
}
});
StyledDialog dialog = builder.create();
mIntentInformationDialog = dialog;
return dialog;
}
Aggregations