Android学习-第39天

今天的任务为创建BeatBox应用,代码如下:

fragment_beat_box.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>


BeatBoxFragment.java:

package com.bignerdranch.android.beatbox;

import android.support.v4.app.Fragment;

public class BeatBoxFragment extends Fragment {
    public static BeatBoxFragment newInstance(){
        return new BeatBoxFragment();
    }
}

BeatBoxActivity.java:

package com.bignerdranch.android.beatbox;

import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class BeatBoxActivity extends SingleFragmentActivity {

    @Override
    protected Fragment createFragment(){
       return BeatBoxFragment.newInstance();
    }
}

activity_fragment.xml:

<FrameLayout android:id="@+id/fragment_container"
             xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="match_parent"
             android:layout_height="match_parent" />



阅读更多

没有更多推荐了,返回首页