Exemple #1
1
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();

    setContentView(R.layout.note_edit);
    setTitle(R.string.edit_note);

    mTitleText = (EditText) findViewById(R.id.title);
    mBodyText = (EditText) findViewById(R.id.body);

    Button confirmButton = (Button) findViewById(R.id.confirm);

    mRowId =
        (savedInstanceState == null)
            ? null
            : (Long) savedInstanceState.getSerializable(NotesDbAdapter.KEY_ROWID);
    if (mRowId == null) {
      Bundle extras = getIntent().getExtras();
      mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
    }

    populateFields();

    confirmButton.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
          }
        });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.notes_list);

    // Initialise database connection and read notes
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();
    fillData();

    registerForContextMenu(getListView());

    // Read preferences
    pref = getPreferences(MODE_PRIVATE);
    requestToken = pref.getString(REQUEST_TOKEN_PREF_KEY, null);
    accessToken = pref.getString(ACCESS_TOKEN_PREF_KEY, null);
    tokenSecret = pref.getString(TOKEN_SECRET_PREF_KEY, null);
    automaticSync = pref.getBoolean(getString(R.string.sync_option), true);

    // Create object for connection with Opera Link
    if (accessToken != null && tokenSecret != null) {
      isConnected = true;
      link =
          LinkClient.createFromAccessToken(consumerKey, consumerSecret, accessToken, tokenSecret);
      if (automaticSync) {
        syncItems();
      }
    } else if (requestToken != null) {
      link =
          LinkClient.createFromRequestToken(consumerKey, consumerSecret, requestToken, tokenSecret);
    } else {
      link = new LinkClient(consumerKey, consumerSecret);
    }
  }
Exemple #3
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.notepad_list);
   mDbHelper = new NotesDbAdapter(this);
   mDbHelper.open();
   fillData();
 }
Exemple #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subjectslist);
    mDbHelper = new SubjectDbAdapter(this);
    mDbHelper.open();
    nDbHelper = new NotesDbAdapter(this);
    nDbHelper.open();
    fillData();

    if (mDbHelper.countSubjects() < 1) {
      Toast.makeText(getApplicationContext(), "No subject(s)", Toast.LENGTH_SHORT).show();
    }

    ListView list = getListView();

    list.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Pair temp = (Pair) arg1.getTag();
            delete_id = temp.getId();
            showDeleteDialog();
            // TODO Auto-generated method stub
            return false;
          }
        });

    Button addsubject = (Button) findViewById(R.id.addbuttonsubj);

    addsubject.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addsubject();
          }
        });
  }