Temp 粗略的导航及界面

master
liuyx 2 years ago
parent 280bb1e94e
commit b8dbff9911

@ -15,12 +15,14 @@ import com.google.android.material.navigation.NavigationBarView;
import cc.liuyx.app.fragment.InfoFragment;
import cc.liuyx.app.fragment.MainFragment;
import cc.liuyx.app.fragment.ScheduleFragment;
public class MainActivity extends AppCompatActivity {
private BottomNavigationView bottomNavigationView;
private MainFragment mainFragment;
private InfoFragment infoFragment;
private ScheduleFragment scheduleFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -36,6 +38,7 @@ public class MainActivity extends AppCompatActivity {
bottomNavigationView = findViewById(R.id.bottom_nav);
mainFragment = new MainFragment();
infoFragment = new InfoFragment();
scheduleFragment = new ScheduleFragment();
initView();
}
@ -73,6 +76,10 @@ public class MainActivity extends AppCompatActivity {
fragment = infoFragment;
tag = "fm_info";
break;
case R.id.schedule:
fragment = scheduleFragment;
tag = "fm_schedule";
break;
}
assert fragment != null;
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, tag).commit();

@ -0,0 +1,17 @@
package cc.liuyx.app.adapter;
import android.content.Context;
import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import java.util.List;
import cc.liuyx.app.entity.Article;
public class ArticleAdapter extends ArrayAdapter<Article> {
public ArticleAdapter(@NonNull Context context, int resource, @NonNull List<Article> objects) {
super(context, resource, objects);
}
}

@ -0,0 +1,41 @@
package cc.liuyx.app.entity;
public class Article {
private int id;
private String title;
private String content;
public Article() {
}
public Article(String title, String content) {
this.title = title;
this.content = content;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

@ -18,8 +18,8 @@ public class User {
@ColumnInfo(name = "email")
private String email;
public User() {
}
// public User() {
// }
public User(String name, String passwd, String phone, String email) {
this.name = name;
@ -28,11 +28,6 @@ public class User {
this.email = email;
}
public User(String name, String passwd) {
this.name = name;
this.passwd = passwd;
}
public int getId() {
return id;
}

@ -1,19 +1,53 @@
package cc.liuyx.app.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import cc.liuyx.app.R;
import cc.liuyx.app.adapter.ArticleAdapter;
import cc.liuyx.app.entity.Article;
public class MainFragment extends Fragment {
private ArticleAdapter articleAdapter;
private List<Article> articleList;
private ListView listView;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
articleList = new ArrayList<>();
articleList.add(new Article("Hello1", "测试。。。"));
articleList.add(new Article("Hello2", "测试。。。"));
articleList.add(new Article("Hello3", "测试。。。"));
articleList.add(new Article("Hello4", "测试。。。"));
articleList.add(new Article("Hello5", "测试。。。"));
articleList.add(new Article("Hello6", "测试。。。"));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_main, container, false);
View view = inflater.inflate(R.layout.fragment_main, container, false);
// listView = view.findViewById(R.id.article_list);
// initListView();
return view;
}
private void initListView() {
Log.w("Error!", "initview");
articleAdapter = new ArticleAdapter(Objects.requireNonNull(getActivity()), R.layout.fragment_main, articleList);
listView.setAdapter(articleAdapter);
}
}

@ -0,0 +1,19 @@
package cc.liuyx.app.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import cc.liuyx.app.R;
public class ScheduleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_schedule, container, false);
}
}

@ -5,15 +5,78 @@
android:layout_height="match_parent"
tools:context=".fragment.MainFragment">
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent">-->
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center"-->
<!-- android:text="正在制作中~" />-->
<!-- </LinearLayout>-->
<!-- <ListView-->
<!-- android:id="@+id/article_list"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:dividerHeight="@dimen/activity_vertical_margin"-->
<!-- android:layout_height="wrap_content"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="#EBE9E9">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记1"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记2"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记3"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记4"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记5"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记6"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记7"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="正在制作中~" />
android:layout_height="50dp"
android:text="测试笔记8"
android:textSize="22sp"/>
</LinearLayout>

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<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=".fragment.MainFragment">
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent">-->
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center"-->
<!-- android:text="正在制作中~" />-->
<!-- </LinearLayout>-->
<!-- <ListView-->
<!-- android:id="@+id/article_list"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:dividerHeight="@dimen/activity_vertical_margin"-->
<!-- android:layout_height="wrap_content"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="#EBE9E9">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记1"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记2"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记3"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记4"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记5"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记6"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记7"
android:textSize="22sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="测试笔记8"
android:textSize="22sp"/>
</LinearLayout>
</FrameLayout>

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/home"
android:title="Home"
android:title="笔记"
android:icon="@drawable/ic_edit"/>
<item android:id="@+id/schedule"
android:title="代办"
android:icon="@drawable/ic_edit"/>
<item android:id="@+id/me"
android:title="Me"
android:title="我的"
android:icon="@drawable/ic_setting"/>
</menu>
Loading…
Cancel
Save