Skip to content

Commit

Permalink
Merge pull request #1749 from zglx/master
Browse files Browse the repository at this point in the history
#4 #1094 231第四次实验
  • Loading branch information
zengsn authored May 11, 2018
2 parents ad51421 + 36d9f3f commit ab4d635
Show file tree
Hide file tree
Showing 11 changed files with 308 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);
}
/*
设置初始状态值
*/

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 116 additions & 7 deletions soft1614080902231/app/src/main/res/layout/activity_sec.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/mToplayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
android:orientation="horizontal"
>
<TextView
android:id="@+id/china"
android:layout_width="86dp"
android:layout_height="42dp"
android:text="中超"
android:gravity="center"
android:textColor="#666666" />
<TextView
android:id="@+id/england"
android:layout_width="86dp"
android:layout_height="42dp"
android:text="英超"
android:gravity="center"
android:textColor="#666666" />
<TextView
android:id="@+id/spanish"
android:layout_width="86dp"
android:layout_height="42dp"
android:text="西甲"
android:gravity="center"
android:textColor="#666666" />
<TextView
android:id="@+id/NBA"
android:layout_width="86dp"
android:layout_height="42dp"
android:text="NBA"
android:gravity="center"
android:textColor="#666666" />
<SearchView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="@android:color/white"
android:orientation="vertical">

<TextView
android:layout_width="fill_parent"
android:layout_height="283dp"
android:text="这是第二页"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false" />
<FrameLayout
android:id="@+id/mBodylayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
</LinearLayout>
<LinearLayout
android:id="@+id/mBottomLayout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:background="#F2F2F2"
android:orientation="horizontal">

</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/mCharacter"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1">

<TextView
android:id="@+id/tv_character"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
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/mPlay"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1">
<TextView
android:id="@+id/tv_play"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:gravity="center"
android:singleLine="true"
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>
Binary file added soft1614080902231/r41.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added soft1614080902231/r42.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added soft1614080902231/r43.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added soft1614080902231/r44.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions soft1614080902231/report2.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1. **实验步骤**

1.阅读实验要求:https://github.com/hzuapps/android-labs-2018/labels/Lab
1.阅读实验要求:

2.在电脑上Android Studio编写代码

3.使用Git将代码提交到自己的库中:https://github.com/ChenchenJT/android-labs-2018
3.使用Git将代码提交到自己的库中:

$ git pull $ git add 学号目录/* $ git commit "#2 #IS 第二次实验" $ git push

Expand Down
33 changes: 33 additions & 0 deletions soft1614080902231/report4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
第四次实验
=
一.实验目的

1.根据选题要求设计界面布局及控件使用;<br>
2.布局xml及界面控制操作代码提交并截图;<br>
3.将应用运行结果截图。<br>

二.实验要求
-
1.使用一种布局方式,设计所选题目的界面:<br>
2.通过控件ID获取界面对象,执行相关操作:<br>
3.实现界面控件的事件处理,例如点击按钮:<br>
三.实验步骤

1、布局选用RelativeLayout方式<br>
2、分别嵌套LinerLayout、FrameLayout、RelativeLayout布局方式,布局界面的顶部栏、内容栏、底部栏<br>
3、为各种控件、布局命名ID,方便在.Java文件中接收<br>
4、编写.java文件,给控件添加监听,实现点击事件onClick(),点击事件为:清空点击控件状态,给点击控件新的状态,如切换颜色<br>

四、实验截图
-
![](https://github.com/zglx/android-labs-2018/blob/master/soft1614080902231/r41.png)

![](https://github.com/zglx/android-labs-2018/blob/master/soft1614080902231/r42.png)

![](https://github.com/zglx/android-labs-2018/blob/master/soft1614080902231/r43.png)

![](https://github.com/zglx/android-labs-2018/blob/master/soft1614080902231/r44.png)

五、实验体会
-
这次实验,我是通学习书上有关的代码,了解了Android的布局,感觉在.java文件编写控件事件很难,发生错误时,APP会停止运行

0 comments on commit ab4d635

Please sign in to comment.