コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_compose);
    client = TwitterApplication.getRestClient();
    etTweetMsg = (EditText) findViewById(R.id.etTweetMsg);
    Button btComposeTweet = (Button) findViewById(R.id.btComposeTweet);
    btComposeTweet.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            tweetMsg = etTweetMsg.getText().toString();
            client.submitTweet(
                tweetMsg,
                new JsonHttpResponseHandler() {
                  // SUCCESS

                  public void onSuccess(int statusCode, JSONObject json) {

                    Log.d("Debug on Success", json.toString());
                  }

                  // FAILURE
                  public void onFailure(
                      int statusCode, Throwable throwable, JSONObject errorResponse) {
                    Log.d("DEBUG PopulateTimeline", errorResponse.toString());
                  }
                });
            Intent timelineIntent = new Intent(ComposeActivity.this, TimeLineActivity.class);
            startActivity(timelineIntent);
          }
        });
  }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_time_line);
    client = TwitterApplication.getRestClient();
    populateTimeLine();

    // find the list view
    lvTweets = (ListView) findViewById(R.id.lvTimeLine);
    // Attach the listener to the AdapterView onCreate
    lvTweets.setOnScrollListener(
        new EndlessScrollListener() {
          @Override
          public void onLoadMore(int page, int totalItemsCount) {
            // Triggered only when new data needs to be appended to the list
            // Add whatever code is needed to append new items to your AdapterView
            customLoadMoreDataFromApi(page);
            // or customLoadMoreDataFromApi(totalItemsCount);
          }
        });
    // Create the arraylist of datasource
    tweets = new ArrayList<>();
    // Construct the adapter from data source
    atweets = new TweetsArrayAdapter(this, tweets);
    // Connect adapter to listview
    lvTweets.setAdapter(atweets);
  }