##晚自习主函数代码
package com.example.myapplication.evening;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import com.example.myapplication.R;
import com.example.myapplication.evening_fragment.BlankFragment_EveningPractice1;
public class EveningPractice extends AppCompatActivity {
private LinearLayout ll;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_evening_practice);
ll=findViewById(R.id.show_evening_linear);
//获取管理
FragmentManager fm = getFragmentManager();
//开启事务
FragmentTransaction ft = fm.beginTransaction();
//添加fragment
BlankFragment_EveningPractice1 blankFragment_eveningPractice1 = new BlankFragment_EveningPractice1();
ft.add(R.id.show_evening_linear,new Fragment());
}
}
##布局
<?xml version="1.0" encoding="utf-8"?>
##fragment布局
package com.example.myapplication.evening_fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.myapplication.R;
/**
-
A simple {@link Fragment} subclass.
*/
public class BlankFragment_EveningPractice1 extends Fragment {public BlankFragment_EveningPractice1() {
// Required empty public constructor
}@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank_fragment__evening_practice1, container, false);
}
}
##fragment的xml布局
<?xml version="1.0" encoding="utf-8"?><!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="这是我晚自习的fragment"
/>
##通过xml改变导航栏的RadioButton的图片以及字体颜色
<?xml version="1.0" encoding="utf-8"?>
##上文的java代码
package com.example.myapplication.afternoon;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.example.myapplication.R;
public class select extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select);
}
}
啥都没写,也没这个必要。