Skip to content

Commit

Permalink
hzuapps#2 hzuapps#19 第二次作业
Browse files Browse the repository at this point in the history
  • Loading branch information
trjie committed Apr 19, 2017
1 parent 4e59350 commit 0a3cf27
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="edu.hzuapps.androidlabs.homework.net1414080903234.Net1414080903234_M">

<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment"
android:gravity="center"
android:id="@+id/tview"/>

</FrameLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package edu.hzuapps.androidlabs.homework.net1414080903234;

/**
* Created by admin on 2017/4/14.
*/

public class Income {
private String drawee;
private double income;
private String in_date;
public void Income(String user,double in, String date){
drawee = user;
income = in;
in_date = date;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,108 @@

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

public class Net1414080903234Activity extends AppCompatActivity {
import org.w3c.dom.Text;

public class Net1414080903234Activity extends AppCompatActivity implements View.OnClickListener {

private TextView tabmoney;
private TextView tabincome;
private TextView taboutlay;
private TextView tabsetting;

private FrameLayout ly_content;
private Net1414080903234_M f1,f2,f3,f4;
private android.app.FragmentManager fragmentManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1414080903234);
bindView();
tabmoney.performClick();
}

protected void bindView(){
tabmoney = (TextView)this.findViewById(R.id.text_money);
tabincome = (TextView)this.findViewById(R.id.text_income);
taboutlay = (TextView)this.findViewById(R.id.text_outlay);
tabsetting = (TextView)this.findViewById(R.id.text_setting);

tabmoney.setOnClickListener(this);
tabincome.setOnClickListener(this);
taboutlay.setOnClickListener(this);
tabsetting.setOnClickListener(this);
}

public void selected(){
tabmoney.setSelected(false);
tabincome.setSelected(false);
taboutlay.setSelected(false);
tabsetting.setSelected(false);
}
public void hideAllFragment(android.app.FragmentTransaction transaction){
if(f1!= null){
transaction.hide(f1);
}
if(f2!=null){
transaction.hide(f2);
}
if(f3!=null){
transaction.hide(f3);
}
if(f4!=null){
transaction.hide(f4);
}
}

@Override
public void onClick(View v) {
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
hideAllFragment(transaction);
switch(v.getId()) {
case R.id.text_money:
selected();
tabmoney.setSelected(true);
if (f1 == null) {
f1 = new Net1414080903234_M().newInstance("总额");
transaction.add(R.id.ly_content, f1);
} else {
transaction.show(f1);
}
break;
case R.id.text_income:
selected();
tabincome.setSelected(true);
if (f2 == null) {
f2 = new Net1414080903234_M().newInstance("收入");
transaction.add(R.id.ly_content, f2);
} else {
transaction.show(f2);
}
break;
case R.id.text_outlay:
selected();
taboutlay.setSelected(true);
if (f3 == null) {
f3 = new Net1414080903234_M().newInstance("支出");
transaction.add(R.id.ly_content, f3);
} else {
transaction.show(f3);
}
break;
case R.id.text_setting:
selected();
tabsetting.setSelected(true);
if (f4 == null) {
f4 = new Net1414080903234_M().newInstance("设置");
transaction.add(R.id.ly_content, f4);
} else {
transaction.show(f4);
}
}
transaction.commit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package edu.hzuapps.androidlabs.homework.net1414080903234;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Net1414080903234_M.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Net1414080903234_M#newInstance} factory method to
* create an instance of this fragment.
*/
public class Net1414080903234_M extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER

// TODO: Rename and change types of parameters
private String mContext;
private TextView mTextview;
private OnFragmentInteractionListener mListener;

public Net1414080903234_M() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @return A new instance of fragment Net1414080903234_M.
*/
// TODO: Rename and change types and number of parameters
public static Net1414080903234_M newInstance(String message) {
Net1414080903234_M fragment = new Net1414080903234_M();
Bundle args = new Bundle();
args.putString("message", message);
fragment.setArguments(args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment

mContext = getArguments().getString("message");
View view = inflater.inflate(R.layout.fragment_net1414080903234__m,container,false);
mTextview = (TextView)view.findViewById(R.id.tview);
mTextview.setText(mContext);
return view;
}

// TODO: Rename method, update argument and hook method into UI event
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package edu.hzuapps.androidlabs.homework.net1414080903234;

/**
* Created by admin on 2017/4/14.
*/

public class Outlay {
private double outlay;
private String usage;
private String out_date;

public Outlay(double out,String use, String date){
outlay = out;
usage = use;
out_date = date;
}
}
68 changes: 64 additions & 4 deletions AndroidLabs/app/src/main/res/layout/activity_net1414080903234.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,68 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="edu.hzuapps.androidlabs.homework.net1414080903234.Net1414080903234Activity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<LinearLayout
android:id="@+id/ly_tab_bar"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginStart="15dp">

<TextView
android:text="总额"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/text_money"
android:layout_weight="1"
android:padding="5dp"
android:textSize="16sp"
android:gravity="center" />

<TextView
android:text="收入"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/text_income"
android:layout_weight="1"
android:padding="5dp"
android:textSize="16sp"
android:gravity="center" />

<TextView
android:text="支出"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/text_outlay"
android:layout_weight="1"
android:padding="5dp"
android:textSize="16sp"
android:gravity="center" />

<TextView
android:text="设置"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/text_setting"
android:layout_weight="1"
android:padding="5dp"
android:textSize="16sp"
android:gravity="center" />
</LinearLayout>
<View
android:id="@+id/div_tab_bar"
android:layout_width="match_parent"
android:layout_height="2px"
android:background="@color/white"
android:layout_above="@id/ly_tab_bar"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/div_tab_bar"
android:id="@+id/ly_content">

</FrameLayout>
</RelativeLayout>

0 comments on commit 0a3cf27

Please sign in to comment.