11package com .guiying .news .main ;
22
33import android .os .Bundle ;
4- import android .support .v7 .app .ActionBar ;
4+ import android .view .View ;
5+ import android .widget .Button ;
6+ import android .widget .Toast ;
57
68import com .github .mzule .activityrouter .annotation .Router ;
7- import com .guiying .common .base .BaseActivity ;
9+ import com .guiying .common .base .BaseActionBarActivity ;
810import com .guiying .common .http .HttpClient ;
911import com .guiying .common .http .OnResultListener ;
1012import com .guiying .common .utils .ToastUtils ;
1113import com .guiying .news .Constants ;
1214import com .guiying .news .R ;
1315import com .orhanobut .logger .Logger ;
1416
17+ import es .dmoral .toasty .Toasty ;
18+
1519@ Router ("news" )
16- public class NewsActivity extends BaseActivity {
20+ public class NewsActivity extends BaseActionBarActivity implements View .OnClickListener {
21+
22+ protected Button mButton ;
23+
24+ @ Override
25+ protected int setTitleId () {
26+ return R .string .news_activity_title ;
27+ }
1728
1829 @ Override
1930 protected void onCreate (Bundle savedInstanceState ) {
2031 super .onCreate (savedInstanceState );
21- setContentView (R .layout .activity_news );
22-
23- //标题栏设置
24- ActionBar actionBar = getSupportActionBar ();
25- if (actionBar != null ) {
26- actionBar .setDisplayHomeAsUpEnabled (true );
27- actionBar .setTitle (R .string .news_activity_title );
28- }
32+ super .setContentView (R .layout .activity_news );
2933 login ();
34+ initView ();
3035 }
3136
3237
@@ -43,7 +48,7 @@ private void login() {
4348
4449 @ Override
4550 public void onSuccess (String result ) {
46- ToastUtils . showLongToast ( result );
51+ Toasty . info ( NewsActivity . this , "Here is some info for you." , Toast . LENGTH_SHORT , true ). show ( );
4752 }
4853
4954 @ Override
@@ -58,9 +63,16 @@ public void onFailure(String message) {
5863 });
5964 }
6065
66+
6167 @ Override
62- public boolean onSupportNavigateUp () {
63- onBackPressed ();
64- return true ;
68+ public void onClick (View view ) {
69+ if (view .getId () == R .id .button1 ) {
70+ ToastUtils .showShortToast ("kannidmfdsfsf " );
71+ }
72+ }
73+
74+ private void initView () {
75+ mButton = (Button ) findViewById (R .id .button1 );
76+ mButton .setOnClickListener (NewsActivity .this );
6577 }
6678}
0 commit comments