diff --git a/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java b/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java index 0387a21..8436332 100644 --- a/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java +++ b/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java @@ -5,14 +5,14 @@ import android.util.Log; import android.view.View; import android.widget.TextView; +import android.widget.Toast; import com.github.xiaogegechen.library.TrackView; public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; - - private boolean state = false; + private int num = 0; @Override protected void onCreate(Bundle savedInstanceState) { @@ -22,7 +22,6 @@ protected void onCreate(Bundle savedInstanceState) { final TrackView trackView = findViewById (R.id.track_view); final TextView textView = findViewById (R.id.text_view); - textView.setOnClickListener (new View.OnClickListener () { @Override public void onClick(View v) { @@ -33,16 +32,30 @@ public void onClick(View v) { trackView.setOnClickListener (new View.OnClickListener () { @Override public void onClick(View v) { + textView.setText ("WORLD"); + Toast.makeText (MainActivity.this, "click", Toast.LENGTH_SHORT).show (); + } + }); - TrackView.Position position = trackView.getPosition (); - Log.d (TAG, "onClick: " + position); + findViewById (R.id.close).setOnClickListener (new View.OnClickListener () { + @Override + public void onClick(View v) { + trackView.close (); + } + }); - if(!state){ - trackView.close (); - }else{ - trackView.open (); - } - state = !state; + findViewById (R.id.open).setOnClickListener (new View.OnClickListener () { + @Override + public void onClick(View v) { + trackView.open (); + } + }); + + findViewById (R.id.change).setOnClickListener (new View.OnClickListener () { + @Override + public void onClick(View v) { + trackView.setText ("num:"+num); + num++; } }); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 74849a4..9527729 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -3,8 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#00FFFFFF" android:layout_width="match_parent" + android:orientation="vertical" android:layout_height="match_parent"> - + +