Android Open Source - SwitchButton Main Activity






From Project

Back to project page SwitchButton.

License

The source code is released under:

MIT License

If you think the Android project SwitchButton listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kyleduo.switchbutton.demo;
//  ww  w . j a v  a  2 s. c o m
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;


public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {

  private ListView mListView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mListView = (ListView) findViewById(R.id.list);
    mListView.setOnItemClickListener(this);
  }


  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    int id = item.getItemId();
    switch (id) {
      case R.id.action_github:
        intent.setData(Uri.parse("https://github.com/kyleduo/SwitchButton"));
        startActivity(intent);
        return true;
      case R.id.action_blog:
        intent.setData(Uri.parse("http://www.kyleduo.com"));
        startActivity(intent);
        return true;
      default:
        break;
    }
    return super.onOptionsItemSelected(item);
  }

  private void jumpToStyle() {
    startActivity(new Intent(this, StyleActivity.class));
  }

  private void jumpToUse() {
    startActivity(new Intent(this, UseActivity.class));
  }

  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
      case 0:
        jumpToStyle();
        break;

      case 1:
        jumpToUse();
        break;

      default:
        break;
    }
  }

}




Java Source Code List

com.kyleduo.switchbutton.AnimationController.java
com.kyleduo.switchbutton.Configuration.java
com.kyleduo.switchbutton.SwitchButton.java
com.kyleduo.switchbutton.demo.MainActivity.java
com.kyleduo.switchbutton.demo.StyleActivity.java
com.kyleduo.switchbutton.demo.UseActivity.java
com.kyleduo.switchbutton.switchbutton.AnimationController.java
com.kyleduo.switchbutton.switchbutton.ApplicationTest.java
com.kyleduo.switchbutton.switchbutton.ApplicationTest.java
com.kyleduo.switchbutton.switchbutton.Configuration.java
com.kyleduo.switchbutton.switchbutton.SwitchButton.java
com.kyleduo.switchbuttondemo.MainActivity.java
com.kyleduo.switchbuttondemo.StyleActivity.java
com.kyleduo.switchbuttondemo.UseActivity.java