From b7c6047a98f54a26f3b2107129d16f3e493ecd07 Mon Sep 17 00:00:00 2001 From: zhengzhengxiaogege <2265949083@qq.com> Date: Wed, 22 May 2019 13:38:18 +0800 Subject: [PATCH] fix bugs --- .../xiaogegechen/trackview/MainActivity.java | 35 ++++++++++----- app/src/main/res/layout/activity_main.xml | 44 +++++++++++-------- .../xiaogegechen/library/TrackView.java | 13 +++--- 3 files changed, 54 insertions(+), 38 deletions(-) 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"> - + +