private void setSubtitle(CharSequence subtitle) {
   if (!TextUtils.equals(subtitle, mActionBar.getSubtitle())) {
     mActionBar.setSubtitle(subtitle);
   }
   if (mLegacySubTitle != null) {
     mLegacySubTitle.setText(subtitle);
   }
 }
  /**
   * Shows TalkBack's abbreviated version number in the action bar, and the full version number in
   * the Play Store button.
   */
  private void showTalkBackVersion() {
    try {
      final PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);

      final ActionBar actionBar = getActionBar();
      if (actionBar != null) {
        actionBar.setSubtitle(
            getString(R.string.talkback_preferences_subtitle, packageInfo.versionName));
      }

      final Preference playStoreButton = findPreferenceByResId(R.string.pref_play_store_key);
      if (playStoreButton == null) {
        return;
      }

      if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) != ConnectionResult.SUCCESS) {
        // Not needed, but playing safe since this is hard to test outside of China
        playStoreButton.setIntent(null);
        final PreferenceGroup category =
            (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key);
        if (category != null) {
          category.removePreference(playStoreButton);
        }
      }

      if (playStoreButton.getIntent() != null
          && getPackageManager().queryIntentActivities(playStoreButton.getIntent(), 0).size()
              == 0) {
        // Not needed, but playing safe since this is hard to test outside of China
        playStoreButton.setIntent(null);
        final PreferenceGroup category =
            (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key);
        if (category != null) {
          category.removePreference(playStoreButton);
        }
      } else {
        final String versionNumber = String.valueOf(packageInfo.versionCode);
        final int length = versionNumber.length();

        playStoreButton.setSummary(
            getString(
                R.string.summary_pref_play_store,
                String.valueOf(Integer.parseInt(versionNumber.substring(0, length - 7)))
                    + "."
                    + String.valueOf(
                        Integer.parseInt(versionNumber.substring(length - 7, length - 5)))
                    + "."
                    + String.valueOf(
                        Integer.parseInt(versionNumber.substring(length - 5, length - 3)))
                    + "."
                    + String.valueOf(Integer.parseInt(versionNumber.substring(length - 3)))));
      }

    } catch (NameNotFoundException e) {
      // Nothing to do if we can't get the package name.
    }
  }
 public void setSubtitle(String subtitle) {
   Activity a = getActivity();
   if (a != null) {
     ActionBar ab = a.getActionBar();
     if (ab != null) {
       ab.setSubtitle(subtitle);
     }
   }
 }
 @Override
 protected void onProgressUpdate(String... values) {
   super.onProgressUpdate(values);
   if (titleTextBox != null) titleTextBox.setText(updating + " " + values[0] + "...");
   if (Build.VERSION.SDK_INT >= 11) {
     ActionBar ab = getActionBar();
     if (ab != null) ab.setSubtitle(updating + " " + values[0] + "...");
   }
 }
 /**
  * Updates the status on the action bar.
  *
  * @param subTitle status
  */
 private void setStatus(CharSequence subTitle) {
   FragmentActivity activity = getActivity();
   if (null == activity) {
     return;
   }
   final ActionBar actionBar = activity.getActionBar();
   if (null == actionBar) {
     return;
   }
   actionBar.setSubtitle(subTitle);
 }
 /**
  * Updates the status on the action bar.
  *
  * @param resId a string resource ID
  */
 private void setStatus(int resId) {
   FragmentActivity activity = getActivity();
   if (null == activity) {
     return;
   }
   final ActionBar actionBar = activity.getActionBar();
   if (null == actionBar) {
     return;
   }
   actionBar.setSubtitle(resId);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_locations_main, container, false);

    ActionBar actionBar = MainActivity.instance.getActionBar();

    // set title
    actionBar.setTitle(R.string.actionbar_info);
    actionBar.setSubtitle(R.string.info_button_locations);

    // enable up navigation
    actionBar.setDisplayHomeAsUpEnabled(true);

    return v;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // set action bar title and subtitle
    ActionBar actionBar = getActionBar();
    actionBar.setTitle("Flash Reporting v2015.08.01b");
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy   HH:mm:ss");
    String dateString = formatter.format(new Date());
    actionBar.setSubtitle(dateString);

    ft = getFragmentManager().beginTransaction();
    ft.add(R.id.container_fragmain, fragMain);
    ft.add(R.id.container_fraglist, fragList);
    ft.commit();
  }
Beispiel #9
0
    @Override
    protected void onPostExecute(final Void unused) {

      // update UI with my objects

      Calendar cal_now = Calendar.getInstance();

      System.out.println(id);
      System.out.println(id);
      cal_now.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY));
      cal_now.set(Calendar.MINUTE, cal.get(Calendar.MINUTE));
      hour = cal_now.get(Calendar.HOUR_OF_DAY);
      minute = cal_now.get(Calendar.MINUTE);
      cal = cal_now;
      updateui();
      ActionBar actionBar = getActionBar();
      actionBar.setTitle(taskname);
      actionBar.setSubtitle("Go back to discard changes");
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ColorDrawable cd = new ColorDrawable(Color.rgb(68, 74, 83));
    mActionBar = getActionBar();
    mActionBar.setBackgroundDrawable(cd);

    cd.setAlpha(0);

    mActionBar.setDisplayHomeAsUpEnabled(true); // to activate back pressed on home button press
    mActionBar.setDisplayShowHomeEnabled(false); //
    mActionBar.setTitle("Menu");
    mActionBar.setSubtitle("Sub_Menu");

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll);
    addTextViews(linearLayout);

    CustomScrollView scrollView = (CustomScrollView) findViewById(R.id.scroll_view);
    scrollView.setOnScrollViewListener(
        new OnScrollViewListener() {

          @Override
          public void onScrollChanged(CustomScrollView v, int l, int t, int oldl, int oldt) {

            cd.setAlpha(getAlphaforActionBar(v.getScrollY()));
          }

          private int getAlphaforActionBar(int scrollY) {
            int minDist = 0, maxDist = 650;
            if (scrollY > maxDist) {
              return 255;
            } else if (scrollY < minDist) {
              return 0;
            } else {
              int alpha = 0;
              alpha = (int) ((255.0 / maxDist) * scrollY);
              return alpha;
            }
          }
        });
  }
  public void init() {
    // Set ActionBar Subtitle
    ActionBar ab = getActionBar();
    ab.setSubtitle(R.string.title_activity_transfer);

    Intent callerIntent = getIntent();
    try {
      res = new JSONObject(callerIntent.getStringExtra("wizglobal.balRes"));
      accountList = new JSONArray(callerIntent.getStringExtra("wizglobal.accountList"));
      Log.d(Config.getDebugTag(), "Account List: " + accountList);
      selectedAccNo = res.getString("accNo");
      selectedAccDesc = res.getString("accDesc");
      Log.d(Config.getDebugTag(), "Account Desc: " + selectedAccDesc);
      balance = res.getString("balance");
      // Inputs
      txtAccNo = (TextView) findViewById(R.id.txtTransAccNo);
      txtBal = (TextView) findViewById(R.id.txtTransBal);
      // Set AccNo and Bal
      txtAccNo.setText(selectedAccDesc);
      txtBal.setText("KES " + balance);

      // Initialize Spinner
      accountNoList = new ArrayList<String>();
      accountDescList = new ArrayList<String>();
      for (int i = 0; i < accountList.length(); i++) {
        accountNoList.add(accountList.getJSONObject(i).getString("accountNo"));
        accountDescList.add(accountList.getJSONObject(i).getString("accountName"));
      }
      accountDescList.remove(selectedAccDesc);
      ArrayAdapter<CharSequence> adapter =
          new ArrayAdapter<CharSequence>(
              this,
              R.layout.wizglobal_spinner_items,
              accountDescList.toArray(new String[accountDescList.size()]));
      Spinner spinnerAccountList = (Spinner) findViewById(R.id.accountSpinner);
      spinnerAccountList.setPrompt(getResources().getString(R.string.spinnerAccountPrompt));
      spinnerAccountList.setAdapter(adapter);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void init() {
    // Set ActionBar Subtitle
    ActionBar ab = getActionBar();
    ab.setSubtitle(R.string.title_activity_product_list_nav);

    Intent callingIntent = getIntent();
    String list = callingIntent.getStringExtra("wizglobal.productListNav");
    try {
      productList = new JSONArray(list);
      String[] descriptions = new String[productList.length()];
      for (int i = 0; i < productList.length(); i++) {
        descriptions[i] = productList.getJSONObject(i).getString("descript");
      }
      ListView lvPLNav = (ListView) findViewById(R.id.lvPLNav);
      String action = "GetPriceListNAV";
      lvPLNav.setAdapter(new SingleListAdapter(this, descriptions, productList, action));
      lvPLNav.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
      lvPLNav.setTextFilterEnabled(true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   updating = context.getString(R.string.updating);
   String s = getString(R.string.getting_tweets) + "...";
   if (updateListAdapter) {
     if (progressBar != null) progressBar.setVisibility(ProgressBar.VISIBLE);
     else {
       dialog = new Dialog(context);
       dialog.setTitle(s);
       dialog.setCancelable(false);
       dialog.show();
     }
   }
   if (titleTextBox != null) {
     titleTextBox.setText(s);
   }
   if (Build.VERSION.SDK_INT >= 11) {
     ActionBar ab = getActionBar();
     if (ab != null) ab.setSubtitle(s);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_timeline);

    mTwitter = TwitterUtils.getTwitterInstance(getApplicationContext());

    SimpleTweetData data =
        (SimpleTweetData) getIntent().getSerializableExtra(TwitterUtils.INTENT_TAG_TWEETDATA);

    if (data == null) {
      showToast(getString(R.string.error_normal));
      finish();
    }

    if (data != null) userScreenName = data.getUserScreenName();

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setSubtitle("@" + userScreenName);
    }

    ListView listView = (ListView) findViewById(R.id.timeline_list_view);
    footerView = getLayoutInflater().inflate(R.layout.listview_footer, null);
    listView.addFooterView(footerView);
    adapter = new HaikuTweetAdapter(this);
    listView.setAdapter(adapter);

    final Button tailButton = (Button) footerView.findViewById(R.id.tail_button);
    tailButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new TimelineAsyncTaskOfTail(adapter).execute();
          }
        });

    headerButton = (Button) findViewById(R.id.button_update);
    headerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new TimelineAsyncTask(adapter).execute();
          }
        });

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (id == -1) return;

            final HaikuStatus status = (HaikuStatus) parent.getAdapter().getItem(position);
            showDialog(status);
          }
        });

    canCreateHaiku = SettingUtils.canCreateHaiku(this);
    new TimelineAsyncTask(adapter).execute();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.themechooser);

    // Google Analytics
    // Get a Tracker (should auto-report)
    ((Frontend) getApplication()).getTracker(Frontend.TrackerName.APP_TRACKER);

    int int_color = Color.parseColor("#222222");
    int ab_theme =
        PreferenceManager.getDefaultSharedPreferences(this).getInt("ab_theme", int_color);
    ActionBar ab = getActionBar();
    ab.setSubtitle("Theme Chooser");
    ab.setBackgroundDrawable(new ColorDrawable(ab_theme));
    ab.setDisplayHomeAsUpEnabled(true);

    final TextView tv1 = (TextView) findViewById(R.id.textView1);
    tv1.setText("Sample");
    tv1.setTextSize(50);

    final ColorPicker picker = (ColorPicker) findViewById(R.id.picker);
    SVBar svBar = (SVBar) findViewById(R.id.svbar);
    OpacityBar opacityBar = (OpacityBar) findViewById(R.id.opacitybar);

    picker.addSVBar(svBar);
    picker.addOpacityBar(opacityBar);

    // To get color
    picker.getColor();

    // To apply previously selected color
    picker.setShowOldCenterColor(true);

    // Intent listener
    final boolean ab_intent = getIntent().getExtras().getBoolean("ab_theme");
    final boolean text_intent = getIntent().getExtras().getBoolean("text_theme");
    final boolean poppy_intent = getIntent().getExtras().getBoolean("poppy_theme");
    final boolean nav_intent = getIntent().getExtras().getBoolean("nav_theme");

    // Applying previously selected color
    // Action bar
    if (ab_intent) {
      ab.setTitle("Action Bar");
      int ab_def_color = Color.parseColor("#222222");
      int ab_color =
          PreferenceManager.getDefaultSharedPreferences(this).getInt("ab_theme", ab_def_color);
      picker.setOldCenterColor(ab_color);
      picker.setColor(ab_color);
      tv1.setTextColor(ab_color);
    }
    // Poppy bar
    if (poppy_intent) {
      ab.setTitle("Poppy Bar");
      int poppy_def_color = Color.parseColor("#222222");
      int poppy_color =
          PreferenceManager.getDefaultSharedPreferences(this)
              .getInt("poppy_theme", poppy_def_color);
      picker.setOldCenterColor(poppy_color);
      picker.setColor(poppy_color);
      tv1.setTextColor(poppy_color);
    }
    // Text color
    if (text_intent) {
      ab.setTitle("Lyrics Text");
      int text_def_color = Color.parseColor("#222222");
      int text_color =
          PreferenceManager.getDefaultSharedPreferences(this).getInt("text_theme", text_def_color);
      picker.setOldCenterColor(text_color);
      picker.setColor(text_color);
      tv1.setTextColor(text_color);
    }
    // Navigation drawer
    if (nav_intent) {
      ab.setTitle("Navigation Drawer");
      int nav_def_color = Color.parseColor("#222222");
      int nav_color =
          PreferenceManager.getDefaultSharedPreferences(this).getInt("nav_theme", nav_def_color);
      picker.setOldCenterColor(nav_color);
      picker.setColor(nav_color);
      tv1.setTextColor(nav_color);
    }

    // Hint colors
    ImageButton ib1 = (ImageButton) findViewById(R.id.imageButton1);
    ImageButton ib2 = (ImageButton) findViewById(R.id.imageButton2);
    ImageButton ib3 = (ImageButton) findViewById(R.id.imageButton3);
    ImageButton ib4 = (ImageButton) findViewById(R.id.imageButton4);
    ImageButton ib5 = (ImageButton) findViewById(R.id.imageButton5);
    // Hint color click listeners
    ib1.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            // int darksky = Color.parseColor("#464ea3");
            picker.setColor(-12165121);
          }
        });
    ib2.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            int frooti = Color.parseColor("#fbba00");
            picker.setColor(frooti);
          }
        });
    ib3.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            int lavender = Color.parseColor("#92278f");
            picker.setColor(lavender);
          }
        });
    ib4.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            int lime = Color.parseColor("#669002");
            picker.setColor(lime);
          }
        });
    ib5.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // int mojo = Color.parseColor("#c84741");
            picker.setColor(-42415);
          }
        });

    picker.setOnColorChangedListener(
        new OnColorChangedListener() {

          @Override
          public void onColorChanged(final int color) {
            // TODO Auto-generated method stub
            tv1.setTextColor(color);

            Button b = (Button) findViewById(R.id.button1);
            b.setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    if (ab_intent) {
                      SharedPreferences sp =
                          PreferenceManager.getDefaultSharedPreferences(ThemeChooser.this);
                      sp.edit().putInt("ab_theme", color).commit();
                      Toast.makeText(ThemeChooser.this, "Applied", Toast.LENGTH_LONG).show();
                      // System.exit(0);
                      onBackPressed();
                    }

                    if (text_intent) {
                      SharedPreferences sp =
                          PreferenceManager.getDefaultSharedPreferences(ThemeChooser.this);
                      sp.edit().putInt("text_theme", color).commit();
                      Toast.makeText(ThemeChooser.this, "Applied", Toast.LENGTH_LONG).show();
                      // System.exit(0);
                      onBackPressed();
                    }

                    if (poppy_intent) {
                      SharedPreferences sp =
                          PreferenceManager.getDefaultSharedPreferences(ThemeChooser.this);
                      sp.edit().putInt("poppy_theme", color).commit();
                      Toast.makeText(ThemeChooser.this, "Applied", Toast.LENGTH_LONG).show();
                      // System.exit(0);
                      onBackPressed();
                    }

                    if (nav_intent) {
                      SharedPreferences sp =
                          PreferenceManager.getDefaultSharedPreferences(ThemeChooser.this);
                      sp.edit().putInt("nav_theme", color).commit();
                      Toast.makeText(ThemeChooser.this, "Applied", Toast.LENGTH_LONG).show();
                      // System.exit(0);
                      onBackPressed();
                    }
                  }
                });
          }
        });
  }
Beispiel #16
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @SuppressLint({"NewApi", "DefaultLocale"})
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainIntent = getIntent();
    HashMap<String, String> element = new HashMap<String, String>();
    yourDir = new File(MainIntent.getStringExtra("PATHSRT"));
    if (yourDir.getParent() != null) {
      element.put("Title", "..");
      element.put("SubTitle", "Parent Directory");
      nameList.add(element);
    }
    getListeRecursiv(yourDir, String.valueOf(yourDir), element);
    Collections.sort(
        nameList,
        new Comparator<HashMap<String, String>>() {
          public int compare(HashMap<String, String> s1, HashMap<String, String> s2) {
            return s1.get("Title").compareToIgnoreCase(s2.get("Title"));
          }
        });
    adapter =
        new SimpleAdapter(
            this,
            nameList,
            android.R.layout.simple_list_item_2,
            new String[] {"Title", "SubTitle"},
            new int[] {android.R.id.text1, android.R.id.text2});
    setListAdapter(adapter);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setSubtitle(yourDir.getAbsolutePath());
    ListView list = this.getListView();
    registerForContextMenu(list);
    list.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            // TODO Auto-generated method stub
            Intent i = new Intent(getApplicationContext(), selectPath.class);
            HashMap<String, String> Hm_name = nameList.get(position);
            name = Hm_name.get("Title"); // =  adapter.getItem(position);
            if (!name.equals("..")) {
              File Test = new File(yourDir + "/" + name);
              if (Test.isFile()) {
                Uri = MediaStore.Files.getContentUri(name);
                i.putExtra("NAMESRT", name);
                i.putExtra("URISRT", String.valueOf(Uri));
                i.putExtra("URI", MainIntent.getStringExtra("URI"));
                i.putExtra("PATHSRT", yourDir.getAbsolutePath());
                i.putExtra("DELAY", MainIntent.getIntExtra("DELAY", 0));
                i.putExtra("SWITCH", MainIntent.getBooleanExtra("SWITCH", false));
                i.putExtra("VIEW", MainIntent.getStringExtra("VIEW"));
                i.putExtra("PATHMP4", MainIntent.getStringExtra("PATHMP4"));
                startActivity(i);
              } else if (Test.isDirectory() && Test.canRead()) {
                Intent intent = new Intent(getApplicationContext(), affich_child.class);
                intent.putExtra("NAMESRT", name);
                intent.putExtra("URISRT", String.valueOf(Uri));
                intent.putExtra("URI", MainIntent.getStringExtra("URI"));
                intent.putExtra("PATHSRT", Test.getAbsolutePath());
                intent.putExtra("DELAY", MainIntent.getIntExtra("DELAY", 0));
                intent.putExtra("SWITCH", MainIntent.getBooleanExtra("SWITCH", false));
                intent.putExtra("VIEW", MainIntent.getStringExtra("VIEW"));
                intent.putExtra("PATHMP4", MainIntent.getStringExtra("PATHMP4"));
                startActivity(intent);
              }
            } else {
              Intent intent = new Intent(getApplicationContext(), affich_child.class);
              intent.putExtra("NAMESRT", name);
              intent.putExtra("URISRT", String.valueOf(Uri));
              intent.putExtra("URI", MainIntent.getStringExtra("URI"));
              intent.putExtra("PATHSRT", yourDir.getParentFile().getAbsolutePath());
              intent.putExtra("DELAY", MainIntent.getIntExtra("DELAY", 0));
              intent.putExtra("SWITCH", MainIntent.getBooleanExtra("SWITCH", false));
              intent.putExtra("VIEW", MainIntent.getStringExtra("VIEW"));
              intent.putExtra("PATHMP4", MainIntent.getStringExtra("PATHMP4"));
              startActivity(intent);
            }
          }
        });
  }
 /**
  * Sets the status bar subtitle
  *
  * @param subTitle
  */
 @TargetApi(11)
 private static final void setStatus(CharSequence subTitle) {
   if (HoneycombOrHigher()) _actionBar.setSubtitle(subTitle);
 }
 /**
  * Sets the status bar subtitle
  *
  * @param resId
  */
 @TargetApi(11)
 private static final void setStatus(int resId) {
   if (HoneycombOrHigher()) _actionBar.setSubtitle(resId);
 }
Beispiel #19
0
  @TargetApi(11)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate(Bundle) called");
    setContentView(R.layout.activity_quiz);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      android.app.ActionBar actionBar = getActionBar();
      actionBar.setSubtitle("Bodies of Water");
    }

    if (savedInstanceState != null) {
      mCurrentIndex = savedInstanceState.getInt(KEY_INDEX, 0);
      mIsCheater = savedInstanceState.getBooleanArray(KEY_CHEATER);
    }

    mQuestionTextView = (TextView) findViewById(R.id.question_text_view);

    mTrueButton = (Button) findViewById(R.id.true_button);
    mTrueButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            checkAnswer(true);
          }
        });

    mFalseButton = (Button) findViewById(R.id.false_button);
    mFalseButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            checkAnswer(false);
          }
        });

    mNextButton = (Button) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
            updateQuestion();
          }
        });

    mPrevButton = (Button) findViewById(R.id.prev_button);
    mPrevButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mCurrentIndex = (mQuestionBank.length + mCurrentIndex - 1) % mQuestionBank.length;
            updateQuestion();
          }
        });

    mQuestionTextView.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
            updateQuestion();
            // TODO Auto-generated method stub

          }
        });

    mCheateButton = (Button) findViewById(R.id.cheat_button);

    mCheateButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent i = new Intent(QuizActivity.this, CheatActivity.class);
            boolean IsCheated = mIsCheater[mCurrentIndex];
            System.out.println(IsCheated);
            boolean answerIsTrue = mQuestionBank[mCurrentIndex].isTrueQuestion();
            i.putExtra(CheatActivity.EXTRA_ANSWER_IS_TRUE, new boolean[] {answerIsTrue, IsCheated});
            // (CheatActivity.EXTRA_ANSWER_IS_TRUE, answerIsTrue);
            startActivityForResult(i, 0);

            // Intent j =new Intent(QuizActivity.this,CheatActivity.class);
            // boolean IsCheated = mIsCheater[mCurrentIndex];
            // j.putExtra(name, value)(CheatActivity.EXTRA_HAS_CHEATED, IsCheated);
            // startActivityForResult(j, 0);
            // startActivity(i);
            // TODO Auto-generated method stub

          }
        });

    updateQuestion();
  }
 @Override
 public void setSubtitle(CharSequence subtitle) {
   mActionBar.setSubtitle(subtitle);
 }
 @SuppressLint("NewApi")
 public boolean onCreateOptionsMenu(Menu menu) {
   ActionBar actionBar = getActionBar();
   actionBar.setSubtitle("Settings");
   return true;
 }
    @SuppressWarnings("unchecked")
    @Override
    protected void onPostExecute(MetaList result) {
      if (updateListAdapter) {
        if (listId < -4) { // saved search
          setListAdapter(
              new TweetAdapter(context, account, R.layout.tweet_list_item, result.getList()));
        } else if (listId == -2) { // direct messages
          setListAdapter(
              new StatusAdapter(
                  context,
                  account,
                  R.layout.tweet_list_item,
                  result.getList(),
                  0,
                  new ArrayList<Long>()));
        } else { // all others
          List<twitter4j.Status> statusList = (List<twitter4j.Status>) result.getList();
          List<Long> reads = obtainReadIds(statusList);
          setListAdapter(
              new StatusAdapter(
                  context,
                  account,
                  R.layout.tweet_list_item,
                  result.getList(),
                  result.oldLast,
                  reads));
        }

        if (result.getList().size() == 0) {
          Toast.makeText(context, "Got no result from the server", Toast.LENGTH_LONG).show();
        }
      }

      if (titleTextBox != null) titleTextBox.setText(account.getAccountIdentifier());
      if (Build.VERSION.SDK_INT >= 11) {
        ActionBar ab = getActionBar();
        if (ab != null) {
          String s = null;
          Map<Integer, Pair<String, String>> userLists = tdb.getLists(account.getId());
          if (userListId != -1) {
            Pair<String, String> nameOwnerPair = userLists.get(userListId);
            if (nameOwnerPair != null) {
              String tmp;
              if (nameOwnerPair.second.equals(account.getName())) tmp = nameOwnerPair.first;
              else tmp = "@" + nameOwnerPair.second + "/" + nameOwnerPair.first;
              s = tmp;
            }
          }
          ab.setTitle(account.getAccountIdentifier());
          ab.setSubtitle(s);
        }
      }
      if (updateListAdapter) getListView().requestLayout();
      if (result.getNumOriginal() > 0) {
        Toast.makeText(context, result.getNumOriginal() + " new items", Toast.LENGTH_SHORT).show();
      }
      if (newMentions > 0) {
        String s = getString(R.string.new_mentions);
        Toast.makeText(context, newMentions + " " + s, Toast.LENGTH_LONG).show();
        newMentions = 0;
      }
      if (newDirects > 0) {
        String s = getString(R.string.new_directs);
        Toast.makeText(context, newDirects + " " + s, Toast.LENGTH_LONG).show();
        newDirects = 0;
      }

      // Only do the next if we actually did an update from twitter
      if (!fromDbOnly && updateListAdapter) {
        Log.i("GTLTask", " scroll to " + result.getNumOriginal());
        // TODO modify to scroll to last-read position
        getListView().setSelection(result.getNumOriginal() - 1);
      }
      if (progressBar != null) progressBar.setVisibility(ProgressBar.INVISIBLE);
      if (dialog != null) dialog.cancel();
    }
 public void setSubtitle(String title) {
   if (mActionBar != null) mActionBar.setSubtitle(title);
 }
 private final void setStatus(int resId) {
   final ActionBar actionBar = getActionBar();
   actionBar.setSubtitle(resId);
 }
 @Override
 public void setSubtitle(int resId) {
   mActionBar.setSubtitle(resId);
 }
 private final void setStatus(CharSequence subTitle) {
   final ActionBar actionBar = getActionBar();
   actionBar.setSubtitle(subTitle);
 }
Beispiel #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(TAG, "onCreate(Bundle) called");

    setContentView(R.layout.activity_quiz);

    Log.d(TAG, "La versión del SDK actual es: " + Build.VERSION.SDK_INT);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      ActionBar actionBar = getActionBar();
      actionBar.setSubtitle("Bodies of Water");
    }

    mTrueButton = (Button) findViewById(R.id.true_button);
    mTrueButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.d(TAG, "Botón TRUE clickeado...");
            checkAnswer(true);
          }
        });
    mFalseButton = (Button) findViewById(R.id.false_button);
    mFalseButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.d(TAG, "Botón FALSE clickeado...");
            checkAnswer(false);
          }
        });

    mQuestionTextView = (TextView) findViewById(R.id.question_text_view);
    mQuestionTextView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            updateQuestion(true);
          }
        });

    mNextButton = (ImageButton) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            //                mIsCheater = false;
            updateQuestion(true);
          }
        });

    mPrevButton = (ImageButton) findViewById(R.id.prev_button);
    mPrevButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            updateQuestion(false);
          }
        });

    mCheatButton = (Button) findViewById(R.id.cheat_button);
    mCheatButton.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {
            Log.d(TAG, "Presionando botón Cheat");
            Intent i = new Intent(QuizActivity.this, CheatActivity.class);
            boolean answerIsTrue = mQuestionBank[mCurrentIndex].isTrueQuestion();
            i.putExtra(CheatActivity.EXTRA_ANSWER_IS_TRUE, answerIsTrue);
            i.putExtra(CURRENT_INDEX, mCurrentIndex);
            startActivityForResult(i, 0);
          }
        });

    if (savedInstanceState != null) {
      Log.d(TAG, "Ya había un valor guardado, recuperando");
      mCurrentIndex = savedInstanceState.getInt(KEY_INDEX, 0);
      //            mIsCheater = savedInstanceState.getBoolean(KEY_IS_CHEATER, false);
      mCheatedQuestionsBank = savedInstanceState.getBooleanArray(CHEATED_VALUES);
      Log.d(TAG, "mCheatedQuestionsBank: " + mCheatedQuestionsBank);
      mCheatedQuestionsBank[mCurrentIndex] = false; // On Rotate, clears "I'm a cheater DATA"
      mNextButton.setEnabled(true);
      mPrevButton.setEnabled(true);
    }

    updateQuestion(null);
  }
  @TargetApi(11)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz_main);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      ActionBar a = getActionBar();
      a.setSubtitle("Water Bodies");
    }
    // updating from the previous state
    if (savedInstanceState != null) {
      mCurrentIndex = savedInstanceState.getInt(INDEX);
      isCheated = savedInstanceState.getBoolean(CheatActivity.IS_CHEATED);
    }
    Log.d(TAG, "onCreate(Bundle savedInstanceState) called");
    // getting the view and setting the question on the view, once.
    mQuestionTextView = (TextView) findViewById(R.id.question_text_view);
    updateQuestion();

    cheatButton = (Button) findViewById(R.id.cheatButton);

    cheatButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            // Start Cheat Activity
            Intent i = new Intent(QuizMainActivity.this, CheatActivity.class);
            boolean answer = mQuestionBank[mCurrentIndex].isTrueQuestion();
            i.putExtra(IS_ANSWER_TRUE, answer);
            startActivityForResult(i, 0);
          }
        });
    mTrueButton = (Button) findViewById(R.id.true_button);
    // Listener
    mTrueButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mQuestionBank[mCurrentIndex].isTrueQuestion()) checkAnswer(true);
            else {
              checkAnswer(false);
            }
          }
        });

    mFalseButton = (Button) findViewById(R.id.false_button);
    // Setting listener
    mFalseButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mQuestionBank[mCurrentIndex].isTrueQuestion() == false) checkAnswer(true);
            else {
              checkAnswer(false);
            }
          }
        });

    mNextButton = (Button) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            isCheated = false;
            mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
            updateQuestion();
          }
        });
  }