public void setRollMode(RollMode rollMode) { switch (rollMode) { case SINGLE: m_rollMode = RollMode.SINGLE; m_resetButton.setEnabled(false); m_dieQuantitySpinner.setEnabled(false); m_dieQuantityTv.setEnabled(false); m_rollSumTv.setVisibility(View.INVISIBLE); m_rollResultList.setVisibility(View.GONE); break; case XDY: m_rollMode = RollMode.XDY; m_resetButton.setEnabled(true); m_dieQuantitySpinner.setEnabled(true); m_dieQuantityTv.setEnabled(true); m_rollSumTv.setVisibility(View.INVISIBLE); m_rollResultList.setVisibility(View.VISIBLE); break; case CUMULATIVE: m_rollMode = RollMode.CUMULATIVE; m_resetButton.setEnabled(true); m_dieQuantitySpinner.setEnabled(true); m_dieQuantityTv.setEnabled(true); m_rollSumTv.setVisibility(View.VISIBLE); m_rollResultList.setVisibility(View.VISIBLE); break; } }
/** Called when the activity is first created */ @Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "LoaderActivity created"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.content); // Instantiate custom adapter mAdapter = new LoaderAdapter(); // Handle listview and assign adapter mListView = (ListView) findViewById(R.id.content_list_view); mListView.setAdapter(mAdapter); mListView.setVisibility(View.GONE); mListView.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { selectItem(position); return true; } }); mStatusLabel = (TextView) findViewById(R.id.content_status_label); mStatusLabel.setVisibility(View.VISIBLE); String userHash = NavigineApp.Settings.getString("user_hash", ""); if (userHash.length() == 0) showUserHashDialog(); else refreshMapList(); }
private void updateLoader() { if (NavigineApp.Navigation == null) return; // Log.d(TAG, String.format(Locale.ENGLISH, "Update loader: %d", mLoader)); long timeNow = DateTimeUtils.currentTimeMillis(); if (mLoader < 0) return; int status = LocationLoader.checkLocationLoader(mLoader); if (status < 100) { if ((Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT / 3 && status == 0) || (Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT)) { mListView.setVisibility(View.GONE); mStatusLabel.setVisibility(View.VISIBLE); mStatusLabel.setText("Loading timeout!\nPlease, check your internet connection!"); Log.d(TAG, String.format(Locale.ENGLISH, "Load stopped on timeout!")); LocationLoader.stopLocationLoader(mLoader); mLoader = -1; } else { mListView.setVisibility(View.GONE); mStatusLabel.setVisibility(View.VISIBLE); mStatusLabel.setText(String.format(Locale.ENGLISH, "Loading content (%d%%)", status)); } } else { Log.d(TAG, String.format(Locale.ENGLISH, "Load finished with result: %d", status)); LocationLoader.stopLocationLoader(mLoader); mLoader = -1; if (status == 100) { parseMapsXml(); if (mInfoList.isEmpty()) { mListView.setVisibility(View.GONE); mStatusLabel.setVisibility(View.VISIBLE); mStatusLabel.setText("No locations available"); } else { mListView.setVisibility(View.VISIBLE); mStatusLabel.setVisibility(View.GONE); } } else { mListView.setVisibility(View.GONE); mStatusLabel.setVisibility(View.VISIBLE); mStatusLabel.setText("Error loading!\nPlease, check your ID!"); } } }
public void setListAdapter(JSONArray jsonArray){ this.jsonArray = jsonArray; GetKeywordsListViewAdapter temp = new GetKeywordsListViewAdapter(this.jsonArray, this); if (text.length() > 0) {//display keywordsListView myKeywordsListView.setVisibility(View.GONE); interestsText.setVisibility(View.GONE); keywordListView.setVisibility(View.VISIBLE); this.keywordListView.setAdapter(temp); } else{//display my keywords myKeywordsListView.setVisibility(View.VISIBLE); interestsText.setVisibility(View.VISIBLE); keywordListView.setVisibility(View.GONE); this.myKeywordsListView.setAdapter(temp); } }
public final void onItemClick(AdapterView adapterview, View view, int i, long l) { b.dismiss(); Cursor cursor = (Cursor) adapterview.getItemAtPosition(i); if (c != 1) { HotelSearchActivity.e(a, cursor.getString(2)); HotelSearchActivity.n(a).setText(HotelSearchActivity.o(a)); HotelSearchActivity.f(a, cursor.getString(1)); ((MyApplication) a.getApplication()).p(com.ll.ctirp.ui.HotelSearchActivity.p(a)); ((MyApplication) a.getApplication()).m(HotelSearchActivity.o(a)); HotelSearchActivity.q(a); } else { HotelSearchActivity hotelsearchactivity = a; String s = cursor.getString(1); if (hotelsearchactivity.b != null) { hotelsearchactivity.b.close(); hotelsearchactivity.b = null; } if (hotelsearchactivity.c != null) { hotelsearchactivity.c.close(); hotelsearchactivity.c = null; } Object obj = LayoutInflater.from(hotelsearchactivity).inflate(0x7f03000d, null); ((View) (obj)).findViewById(0x7f080058); Object obj1 = (EditText) ((View) (obj)).findViewById(0x7f080059); ListView listview = (ListView) ((View) (obj)).findViewById(0x7f08005a); TextView textview1 = (TextView) ((View) (obj)).findViewById(0x7f08005d); TextView textview = (TextView) ((View) (obj)).findViewById(0x7f08005b); ListView listview1 = (ListView) ((View) (obj)).findViewById(0x7f08005c); obj = (new android.app.AlertDialog.Builder(hotelsearchactivity)) .setTitle("选择入住的城市") .setView(((View) (obj))) .create(); ((AlertDialog) (obj)).show(); ((EditText) (obj1)).setVisibility(8); textview1.setVisibility(8); textview.setVisibility(8); listview1.setVisibility(8); obj1 = new ArrayList(); int j = ((MyApplication) hotelsearchactivity.getApplication()).d().size(); for (int k = 0; k < j; k++) if (((HashMap) ((MyApplication) hotelsearchactivity.getApplication()).d().get(k)) .containsValue(s)) ((ArrayList) (obj1)) .add((HashMap) ((MyApplication) hotelsearchactivity.getApplication()).d().get(k)); listview.setAdapter(new p(hotelsearchactivity, ((ArrayList) (obj1)))); listview.setOnItemClickListener( new r(hotelsearchactivity, ((ArrayList) (obj1)), ((AlertDialog) (obj)))); } cursor.close(); }
/** * @param items * @param onItemClickListener * @param specialIndexes 需要标红的item的索引(从上到下从0计数) */ public void setItems( String[] items, final AdapterView.OnItemClickListener onItemClickListener, int[] specialIndexes) { mContentView.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); mListView.setAdapter(new RenrenDialogListAdapter(items, specialIndexes)); mListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { dismiss(); if (onItemClickListener != null) { onItemClickListener.onItemClick(parent, view, position, id); } } }); }
private void load() { loaderPlaceholder.setVisibility(View.VISIBLE); recipesList.setVisibility(View.GONE); connection = new AsyncTask<Void, Void, Response>() { @Override protected Response doInBackground(Void... voids) { return ServerUtilities.getRecipes(categoryId, ingredientId); } protected void onPostExecute(Response response) { super.onPostExecute(response); if (response.getCode() == RESPONSE_CODE_OK) { recipes = (List<Recipe>) response.getObject(); if (recipes.size() > 0) { loaderPlaceholder.setVisibility(View.GONE); recipesList.setVisibility(View.VISIBLE); recipesList.setAdapter(new RecipeAdapter(mContext)); } else { loaderIndicator.setVisibility(View.GONE); loaderFailed.setVisibility(View.VISIBLE); loaderFailed.setText(getString(R.string.recipes_empty)); } } else { loaderIndicator.setVisibility(View.GONE); loaderFailed.setVisibility(View.VISIBLE); loaderRepeat.setVisibility(View.VISIBLE); ((BasicActivity) getActivity()).errorsHandling(response, false); } } }.execute((Void) null); }
/** Create the custom dialog */ @SuppressLint("Override") public ArkBaseDialog create() { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // instantiate the dialog with the custom Theme final ArkBaseDialog dialog = new ArkBaseDialog(context, R.style.alertdialog); View layout = inflater.inflate(R.layout.alert_dialog, null); dialog.addContentView( layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); // set the dialog title TextView titleView = ((TextView) layout.findViewById(R.id.dialog_title_show)); titleView.setText(title); // set the dialog title icon if (0 != title_background) { layout.findViewById(R.id.dialog_title_layout).setBackgroundResource(title_background); } if (0 != title_icon) { titleView.setCompoundDrawablesWithIntrinsicBounds( context.getResources().getDrawable(title_icon), null, null, null); /*ImageView ico = (ImageView) layout.findViewById(R.id.dialog_title_icon); ico.setImageResource(title_icon);*/ if (null != icoClickListener) { titleView.setClickable(true); titleView.setOnClickListener(icoClickListener); } } ListView dialogListView = (ListView) layout.findViewById(R.id.dialog_list); // set the dialog list adpter if (adapter != null) { dialogListView.setAdapter(adapter); // set the dialog list width if (listAutoHeight) { // setListViewHeightBasedOnChildren(dialogListView); } } else { dialogListView.setVisibility(View.GONE); } // set the close button if (closeButtonClickListener != null) { ImageButton imageClose = ((ImageButton) layout.findViewById(R.id.dialog_close)); imageClose.setBackgroundResource(closeButtonRes); TouchHelper.setOnTouchListener(imageClose, 0.85f, 0.85f); imageClose.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { closeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE); } }); } else { // if no confirm button just set the visibility to GONE layout.findViewById(R.id.dialog_close).setVisibility(View.GONE); } // set the confirm button if (positiveButtonText != null) { // int positiveTextLenght = positiveButtonText.length(); ((Button) layout.findViewById(R.id.dialog_confirm_btn)).setText(positiveButtonText); /* ((Button) layout.findViewById(R.id.dialog_confirm_btn)) .setWidth(104 + (positiveTextLenght - 2) * 15);*/ layout.findViewById(R.id.dialog_confirm_btn).setBackgroundResource(positiveButtonRes); if (positiveButtonClickListener != null) { (layout.findViewById(R.id.dialog_confirm_btn)) .setOnClickListener( new View.OnClickListener() { public void onClick(View v) { positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); } }); } } else { // if no confirm button just set the visibility to GONE layout.findViewById(R.id.dialog_confirm_btn).setVisibility(View.GONE); } // set the cancel button if (negativeButtonText != null) { // int negativeTextLenght = negativeButtonText.length(); Button btnCancel = (Button) layout.findViewById(R.id.dialog_cancel_btn); // btnCancel.setWidth(104 + (negativeTextLenght - 2) * 15); btnCancel.setText(negativeButtonText); btnCancel.setBackgroundResource(negativeButtonRes); if (negativeButtonClickListener != null) { btnCancel.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE); } }); } } else { // if no confirm button just set the visibility to GONE layout.findViewById(R.id.dialog_cancel_btn).setVisibility(View.GONE); } // set the content message if (message != null) { ((TextView) layout.findViewById(R.id.dialog_content_show)).setText(message); } else if (contentView != null) { // if no message set // add the contentView to the dialog body ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)).removeAllViews(); ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)) .addView( contentView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); } else if (null != listView) { ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)).removeAllViews(); ((LinearLayout) layout.findViewById(R.id.dialog_content_layout)) .addView( listView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); // setListViewHeightBasedOnChildren(listView); } else { (layout.findViewById(R.id.dialog_content_show)).setVisibility(View.GONE); } dialog.setContentView(layout); dialog.setCanceledOnTouchOutside(true); return dialog; }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.interests); interestsText = (TextView) findViewById(R.id.textView); TelephonyManager tMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mPhoneNumber = tMgr.getLine1Number(); interest = (EditText) findViewById(R.id.myInterest); keywordListView = (ListView) findViewById(R.id.keywordView); keywordListView.setVisibility(View.GONE); myKeywordsListView = (ListView) findViewById(R.id.myKeywordsView); new GetMyKeywordsTask().execute(new ApiConnector()); //registerForContextMenu(myKeywordsListView); myKeywordsListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long arg3) { try { System.out.println("DELETE: " + jsonArray.getJSONObject(position).getString("keyword") + "################################"); keyword = jsonArray.getJSONObject(position).getString("keyword"); } catch(JSONException e){ e.printStackTrace(); } new DeleteMyKeywordTask().execute(new ApiConnector()); return false; } }); addInterest = (Button) findViewById(R.id.addInterest); addInterest.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { keyword = interest.getText().toString(); new InsertKeywordTask().execute(new ApiConnector()); startActivity(new Intent(getApplicationContext(), MyProfile.class)); } }); //pop up keywords already in db interest.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable mEdit) { keywordListView.setVisibility(View.VISIBLE); myKeywordsListView.setVisibility(View.GONE); text = mEdit.toString(); new findKeywordTask().execute(new ApiConnector()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); //autofill the keyword on click this.keywordListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { try { JSONObject itemClicked = jsonArray.getJSONObject(position); interest.setText(itemClicked.getString("keyword")); } catch (JSONException e) { e.printStackTrace(); } } }); }