parent
280bb1e94e
commit
b8dbff9911
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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…
Reference in new issue