Skip to content

Commit

Permalink
hzuapps#4 hzuapps#1094 231第四次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
zglx committed May 10, 2018
1 parent ebc8299 commit 8b3ee83
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,171 @@

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.service.autofill.FillEventHistory;
import android.view.View;
import android.widget.Button;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

public class SecActivity extends Activity {

import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import android.widget.TextView;
public class SecActivity extends Activity implements View.OnClickListener{
/**
* 顶部内容栏
*/
private LinearLayout mTopLayout;
private TextView tv_china;
private TextView tv_england;
private TextView tv_spanish;
private TextView tv_nab;
/**
*
* 中间内容栏,还没有编写
*/
private FrameLayout mBodylayout;
/*
底部内容栏
*/
public LinearLayout mBottomLayout;
private View mCharacter;
private View mPlay;
private TextView tv_characetr;
private TextView tv_play;
private ImageView iv_wenzi;
private ImageView iv_bofang;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sec);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
init();
setListener();
setInitStatues();
setTopStatues(0);
}
private void init()//给控件赋值
{
mTopLayout=(LinearLayout)findViewById(R.id.mToplayout);
tv_china=(TextView)findViewById(R.id.china);
tv_england=(TextView)findViewById(R.id.england);
tv_spanish=(TextView)findViewById(R.id.spanish);
tv_nab=(TextView)findViewById(R.id.NBA);
mBottomLayout=(LinearLayout) findViewById(R.id.mBottomLayout);
mCharacter = findViewById(R.id.mCharacter);
mPlay = findViewById(R.id.mPlay);
tv_characetr = (TextView) findViewById(R.id.tv_character);
tv_play = (TextView) findViewById(R.id.tv_play);
iv_wenzi = (ImageView) findViewById(R.id.iv_wenzi);
iv_bofang = (ImageView)findViewById(R.id.iv_bofang);

}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.mCharacter:
clearBottom();
setSelectStatues(0);
break;
case R.id.mPlay:
clearBottom();
setSelectStatues(1);
break;
case R.id.china:
clearTop();
setTopStatues(0);
break;
case R.id.england:
clearTop();
setTopStatues(1);
break;
case R.id.spanish:
clearTop();
setTopStatues(2);
break;
case R.id.NBA:
clearTop();
setTopStatues(3);
break;
default:
break;
}
}
private void setTopStatues(int index)
{
switch (index)
{
case 0:
mTopLayout.setSelected(true);
tv_china.setTextColor(Color.parseColor("#0097F7"));
break;
case 1:
mTopLayout.setSelected(true);
tv_england.setTextColor(Color.parseColor("#0097F7"));
break;
case 2:
mTopLayout.setSelected(true);
tv_spanish.setTextColor(Color.parseColor("#0097F7"));
break;
case 3:
mTopLayout.setSelected(true);
tv_nab.setTextColor(Color.parseColor("#0097F7"));
break;
}
}
/*
添加点击事件
*/
private void setListener()
{
for(int i=0;i<mBottomLayout.getChildCount();i++)
mBottomLayout.getChildAt(i).setOnClickListener(this);
for(int i=0;i<mTopLayout.getChildCount();i++)
mTopLayout.getChildAt(i).setOnClickListener(this);
}
private void clearBottom()
{

tv_play.setTextColor(Color.parseColor("#666666"));
tv_characetr.setTextColor(Color.parseColor("#666666"));
iv_bofang.setImageResource(R.drawable.nis);
iv_wenzi.setImageResource(R.drawable.ni);
for(int i=0;i<mBottomLayout.getChildCount();i++)
mBottomLayout.getChildAt(i).setSelected(false);
}
}
private void clearTop()
{
tv_china.setTextColor(Color.parseColor("#666666"));
tv_england.setTextColor(Color.parseColor("#666666"));
tv_spanish.setTextColor(Color.parseColor("#666666"));
tv_nab.setTextColor(Color.parseColor("#666666"));
for(int i=0;i<mTopLayout.getChildCount();i++)
mTopLayout.getChildAt(i).setSelected(false);
}
private void setSelectStatues(int index)
{
switch (index)
{
case 0:
mCharacter.setSelected(true);
tv_characetr.setTextColor(Color.parseColor("#0097F7"));
break;
case 1:
mPlay.setSelected(true);
tv_play.setTextColor(Color.parseColor("#0097F7"));
break;

}
}
private void setInitStatues()
{
clearBottom();
setSelectStatues(0);
}
/*
设置初始状态值
*/

}
32 changes: 23 additions & 9 deletions soft1614080902231/app/src/main/res/layout/activity_sec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/mToplayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
Expand All @@ -27,7 +28,7 @@
android:gravity="center"
android:textColor="#666666" />
<TextView
android:id="@+id/Spanish"
android:id="@+id/spanish"
android:layout_width="86dp"
android:layout_height="42dp"
android:text="西甲"
Expand Down Expand Up @@ -57,44 +58,50 @@
android:footerDividersEnabled="false"
android:headerDividersEnabled="false" />
<FrameLayout
android:id="@+id/main_bady"
android:id="@+id/mBodylayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
</LinearLayout>
<LinearLayout
android:id="@+id/main_bottom_bar"
android:id="@+id/mBottomLayout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:background="#F2F2F2"
android:orientation="horizontal">

<RelativeLayout
android:id="@+id/bottom_bar_course_btn"
android:id="@+id/mCharacter"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1">

<TextView
android:id="@+id/bottom_bar_text_course"
android:id="@+id/tv_character"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:singleLine="true"
android:text="文字直播"
android:textColor="#666666"
android:textSize="14sp" />
<ImageView
android:id="@+id/iv_wenzi"
android:layout_width="54dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"

android:src="@drawable/ni" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/bottom_bar_zhipo_btn"
android:id="@+id/mPlay"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1">
<TextView
android:id="@+id/bottom_bar_huifang_course"
android:id="@+id/tv_play"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
Expand All @@ -105,6 +112,13 @@
android:text="精彩回放"
android:textColor="#666666"
android:textSize="14sp" />

<ImageView
android:id="@+id/iv_bofang"
android:layout_width="54dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:src="@drawable/nis" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

0 comments on commit 8b3ee83

Please sign in to comment.