Android北京地铁查询app-代码部分
这次结对作业完成的Android北京地铁查询app的代码,放在这里,
也可以到我github上下载:https://github.com/BXF-Aurora168
页面和功能介绍:https://www.cnblogs.com/rsy-bxf150/p/17265840.html
部分代码:
activity
package com.example.dataapplication; import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.PagerAdapter; import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import com.example.dataapplication.OtherActivity.DynamicFragmentActivity; import com.example.dataapplication.OtherActivity.ViewPagerActivity1; public class MainActivity extends AppCompatActivity{ @SuppressLint("MissingInflatedId") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void onck2(View view) { Intent intent = new Intent(this, PagerActivity.class); startActivity(intent); } }
package com.example.dataapplication; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import com.example.dataapplication.OtherActivity.DynamicFragmentActivity; import com.example.dataapplication.adapter.MyFragStateAdapter; import com.example.dataapplication.fragment.BlankFragment2; import com.example.dataapplication.fragment.frag1.SearchFragment; import com.example.dataapplication.fragment.frag2.LeftListFragment; import com.example.dataapplication.fragment.frag3.MapFragment; import com.google.android.material.badge.BadgeDrawable; import com.google.android.material.bottomnavigation.BottomNavigationView; import java.util.ArrayList; import java.util.List; public class PagerActivity extends AppCompatActivity { private ViewPager mViewPager; private BottomNavigationView mBottomNavigationView; private MyFragStateAdapter FragStateAdapter; private List<Fragment> mFragmentList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pager); mViewPager = findViewById(R.id.vp2); mBottomNavigationView = findViewById(R.id.bottom_menu); initData(); FragStateAdapter = new MyFragStateAdapter(getSupportFragmentManager(),mFragmentList); mViewPager.setAdapter(FragStateAdapter); mBottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()){ case R.id.menu_1: mViewPager.setCurrentItem(0); break; case R.id.menu_2: mViewPager.setCurrentItem(1); break; case R.id.menu_3: mViewPager.setCurrentItem(2); break; default: break; } return true; } }); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { switch (position){ case 0: mBottomNavigationView.setSelectedItemId(R.id.menu_1); break; case 1: mBottomNavigationView.setSelectedItemId(R.id.menu_2); break; case 2: mBottomNavigationView.removeBadge(R.id.menu_3); mBottomNavigationView.setSelectedItemId(R.id.menu_3); break; default: break; } } @Override public void onPageScrollStateChanged(int state) { } }); } private void initData() { mFragmentList = new ArrayList<>(); SearchFragment fragment1 = SearchFragment.newInstance("",""); LeftListFragment fragment2 = LeftListFragment.newInstance("",""); MapFragment fragment3 = MapFragment.newInstance("",""); mFragmentList.add(fragment1); mFragmentList.add(fragment2); mFragmentList.add(fragment3); } }
fragment
package com.example.dataapplication.fragment.frag1; import android.nfc.Tag; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageButton; import android.widget.Toast; import com.example.dataapplication.DataBase.CRUD; import com.example.dataapplication.Infomation.SubwayBean; import com.example.dataapplication.MenuActivity; import com.example.dataapplication.R; import com.example.dataapplication.adapter.ListViewAdapter; import java.util.ArrayList; import java.util.List; public class SearchFragment extends Fragment { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1,mParam2; private EditText mEt_start,mEt_end; private ImageButton mBtn_search; private RecyclerView mList; private List<SubwayBean> mData; private String start,end; public SearchFragment() { } public static SearchFragment newInstance(String param1, String param2) { SearchFragment fragment = new SearchFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_search, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mEt_start = view.findViewById(R.id.frag_et_start); mEt_end = view.findViewById(R.id.frag_et_end); mBtn_search= view.findViewById(R.id.frag_btn_find); mList = view.findViewById(R.id.frag_recycle_show); mBtn_search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { start=mEt_start.getText().toString(); end=mEt_end.getText().toString(); CRUD crud = new CRUD(getContext()); if (crud.ArrayTransferStation(start,end)==null){ Toast.makeText(getContext(), "输入为空或查不到此数据", Toast.LENGTH_SHORT).show(); }else { initData(); } } }); } private void initData() { mData = new ArrayList<SubwayBean>(); CRUD crud = new CRUD(getContext()); //导入数据 ArrayList<SubwayBean> subList = crud.ArrayTransferStation(start,end); for (int i = 0; i < subList.size(); i++) { SubwayBean subway = new SubwayBean(); SubwayBean subData =subList.get(i); subway._StartStation = subData._StartStation; subway._EndStation = subData._EndStation; subway._Number = subData._Number; subway._Path = subData._Path; mData.add(subway); } //设置布局管理器 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); mList.setLayoutManager(linearLayoutManager); //创建适配器 ListViewAdapter adapter = new ListViewAdapter(mData); //设置到listview里 mList.setAdapter(adapter); } }
package com.example.dataapplication.fragment.frag2; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.example.dataapplication.DataBase.CRUD; import com.example.dataapplication.R; import com.example.dataapplication.adapter.LeftListAdapter; import java.util.ArrayList; import java.util.List; public class LeftListFragment extends Fragment { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1; private String mParam2; private RecyclerView mList,mList2; private List<String> mData,mData2; private LeftListAdapter mAdapter,mAdapter2; public LeftListFragment() { } public static LeftListFragment newInstance(String param1, String param2) { LeftListFragment fragment = new LeftListFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_left_list, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mList = view.findViewById(R.id.frag_recycle_left); mList2 = view.findViewById(R.id.frag_recycle_right); initData1(); } private void initData2(int position) { mData2 = new ArrayList<String>(); CRUD crud = new CRUD(getContext()); //导入数据 ArrayList<String> subList = crud.PositionStation(position); for (int i = 0; i < subList.size(); i++) { String stationData = subList.get(i); mData2.add(stationData); } //设置布局管理器 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); mList2.setLayoutManager(linearLayoutManager); //创建适配器 mAdapter2 = new LeftListAdapter(mData2); //设置到listview里 mList2.setAdapter(mAdapter2); } private void initData1() { mData = new ArrayList<String>(); CRUD crud = new CRUD(getContext()); //导入数据 ArrayList<String> subList = crud.getArrayLine(); for (int i = 0; i < subList.size(); i++) { String stationData = subList.get(i); mData.add(stationData); } //设置布局管理器 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); mList.setLayoutManager(linearLayoutManager); //创建适配器 mAdapter = new LeftListAdapter(mData); //设置到listview里 mList.setAdapter(mAdapter); mAdapter.setOnItemClick1(new LeftListAdapter.OnItemClickListener1() { @Override public void OnItemClick1(int position) { initData2(position); } }); } }
package com.example.dataapplication.fragment.frag3; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; import com.example.dataapplication.DataBase.CRUD; import com.example.dataapplication.R; public class MapFragment extends Fragment { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1; private String mParam2; private EditText mEt1; private ImageButton mBtn1; private TextView mTv1; public MapFragment() { } public static MapFragment newInstance(String param1, String param2) { MapFragment fragment = new MapFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_map, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mEt1 = view.findViewById(R.id.map_et_1); mBtn1 = view.findViewById(R.id.map_btn_1); mTv1= view.findViewById(R.id.map_tv_1); mBtn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String text1=mEt1.getText().toString(); CRUD crud = new CRUD(getContext()); String text2 = crud.getLine(text1); if (text2 != null) { mTv1.setText(text1+" 位于 "+text2); }else { Toast.makeText(getContext(), "输入为空或查不到此数据", Toast.LENGTH_SHORT).show(); } } }); } }
crud数据库方法
package com.example.dataapplication.DataBase; import android.annotation.SuppressLint; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.example.dataapplication.Infomation.SubwayBean; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; public class CRUD { private DBHelper dbHelper; public CRUD (Context context){dbHelper = new DBHelper(context);} @SuppressLint("Range") public ArrayList<SubwayBean> ArrayTransferStation(String station1, String station2){ SQLiteDatabase db = dbHelper.getReadableDatabase(); ArrayList<SubwayBean> resultArray = new ArrayList<>(); int i=0; String sql = "WITH RECURSIVE transfer(start_station, stop_station, stops, paths) AS (\n" + "SELECT station_name, next_station, 1 stops, \n" + " line_name||station_name||'->'||line_name||next_station AS paths\n" + "FROM bj_subway\n" + "WHERE station_name = ?\n" + "UNION ALL \n" + "SELECT t.start_station, s.next_station, stops+1, paths||'->'||s.line_name||s.next_station\n" + "FROM transfer t\n" + "JOIN bj_subway s \n" + "ON (t.stop_station = s.station_name AND instr(paths, s.next_station)=0)\n" + ")\n" + "SELECT *\n" + "FROM transfer\n" + "WHERE stop_station = ?;"; Cursor cursor = db.rawQuery(sql,new String[]{station1,station2}); if (cursor.moveToFirst()){ do { i++; SubwayBean subwayBean = new SubwayBean(); subwayBean._StartStation = cursor.getString(cursor.getColumnIndex("start_station")); subwayBean._EndStation = cursor.getString(cursor.getColumnIndex("stop_station")); subwayBean._Number = cursor.getString(cursor.getColumnIndex("stops")); subwayBean._Path = cursor.getString(cursor.getColumnIndex("paths")); resultArray.add(subwayBean); }while (cursor.moveToNext()); } if(i==0) { return null; } cursor.close(); db.close(); return resultArray; } @SuppressLint("Range") public ArrayList<String> PositionStation(int position){ SQLiteDatabase db = dbHelper.getReadableDatabase(); ArrayList<String> ArrayOnly = new ArrayList<>(); int number = 1; switch (position){ case 0:number = 1; break; case 1:number = 2; break; case 2:number = 8; break; case 3:number = 4; break; case 4:number = 5; break; case 5:number = 6; break; case 6:number = 7; break; case 7:number = 9; break; case 8:number = 11; break; case 9:number = 10; break; } String the_line = number+"号"+"线"; String sql = "Select * From bj_subway2 Where line_name=?"; Cursor cursor = db.rawQuery(sql,new String[]{the_line}); int i=0; if (cursor.moveToFirst()){ do { i++; String a = cursor.getString(cursor.getColumnIndex("station_name")); ArrayOnly.add(a); }while (cursor.moveToNext()); } if(i==0) { return null; } cursor.close(); db.close(); return ArrayOnly; } @SuppressLint("Range") public ArrayList<String> getArrayLine(){ SQLiteDatabase db = dbHelper.getReadableDatabase(); ArrayList<String> ArrayLine = new ArrayList<>(); String sql ="Select * From bj_subway2 Where station_id In (Select Max(station_id) From bj_subway2 Group By line_name)"; Cursor cursor = db.rawQuery(sql,null); int i=0; if (cursor.moveToFirst()){ do { i++; String a = cursor.getString(cursor.getColumnIndex("line_name")); ArrayLine.add(a); }while (cursor.moveToNext()); } if(i==0) { return null; } cursor.close(); db.close(); return ArrayLine; } @SuppressLint("Range") public String getLine(String station){ SQLiteDatabase db = dbHelper.getReadableDatabase(); String Line = null; String sql = "Select * From bj_subway2 Where station_name=?"; Cursor cursor = db.rawQuery(sql,new String[]{station}); int i=0; if (cursor.moveToFirst()){ i++; Line = cursor.getString(cursor.getColumnIndex("line_name")); } if(i==0) { return null; } cursor.close(); db.close(); return Line; } }
dbHelper
package com.example.dataapplication.DataBase; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class DBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION=2; private static final String DATABASE_NAME="crud.db"; public DBHelper(Context context) { super(context,DATABASE_NAME,null,DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
adapter
package com.example.dataapplication.adapter; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.dataapplication.Infomation.SubwayBean; import com.example.dataapplication.R; import java.util.List; public class ListViewAdapter extends RecyclerView.Adapter<ListViewAdapter.InnerHolder> { private final List<SubwayBean> mData; public ListViewAdapter(List<SubwayBean> data){this.mData = data;} //创建View @NonNull @Override public InnerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view =View.inflate(parent.getContext(), R.layout.item_list_view,null); return new InnerHolder(view); } @Override public void onBindViewHolder(@NonNull InnerHolder holder, int position) { holder.setData(mData.get(position)); } @Override public int getItemCount() { if (mData != null) { return mData.size(); } return 0; } public class InnerHolder extends RecyclerView.ViewHolder{ private TextView m1,m2,m3,m4; public InnerHolder(@NonNull View itemView) { super(itemView); m1 = itemView.findViewById(R.id.list_1); m2 = itemView.findViewById(R.id.list_2); m3 = itemView.findViewById(R.id.list_3); m4 = itemView.findViewById(R.id.list_4); } public void setData(SubwayBean subwayBean) { m1.setText(subwayBean._StartStation); m2.setText(subwayBean._EndStation); m3.setText("经过站数:"+(CharSequence) subwayBean._Number); m4.setText(subwayBean._Path); } } }
package com.example.dataapplication.adapter; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.dataapplication.Infomation.SubwayBean; import com.example.dataapplication.R; import java.util.List; public class LeftListAdapter extends RecyclerView.Adapter<LeftListAdapter.InnerHolder> { private final List<String> mData; private OnItemClickListener1 mOnItemClickListener1; public LeftListAdapter(List<String> data){this.mData = data;} public void setOnItemClick1(LeftListAdapter.OnItemClickListener1 listener1){ this.mOnItemClickListener1 = listener1; } public interface OnItemClickListener1{ void OnItemClick1(int position); } //创建View @NonNull @Override public InnerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view =View.inflate(parent.getContext(), R.layout.item_list_left,null); return new InnerHolder(view); } @Override public void onBindViewHolder(@NonNull InnerHolder holder, int position) { holder.setData(mData.get(position),position); } @Override public int getItemCount() { if (mData != null) { return mData.size(); } return 0; } public class InnerHolder extends RecyclerView.ViewHolder{ private TextView m1; private int mPosition; public InnerHolder(@NonNull View itemView) { super(itemView); m1 = itemView.findViewById(R.id.item_left_station); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mOnItemClickListener1 != null) { mOnItemClickListener1.OnItemClick1(mPosition); } } }); } public void setData(String station,int position) { this.mPosition = position; m1.setText(station); } } }
package com.example.dataapplication.adapter; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import java.util.List; public class MyFragStateAdapter extends FragmentStatePagerAdapter { private List<Fragment> mFragmentList; public MyFragStateAdapter(@NonNull FragmentManager fm,List<Fragment> fragmentList) { super(fm); this.mFragmentList =fragmentList; } @NonNull @Override public Fragment getItem(int position) { return mFragmentList == null ? null : mFragmentList.get(position); } @Override public int getCount() { return mFragmentList == null ? 0 : mFragmentList.size(); } }
xml
activity_pager
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".PagerActivity" android:orientation="vertical"> <androidx.viewpager.widget.ViewPager android:id="@+id/vp2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> <com.google.android.material.bottomnavigation.BottomNavigationView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/bottom_menu" app:menu="@menu/bottom_nav_menu" app:labelVisibilityMode="labeled" /> </LinearLayout>
fragment_search
<?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="wrap_content" android:layout_margin="0dp" android:background="@drawable/bg_bg1" tools:context=".fragment.frag1.SearchFragment"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text=" 路 线 查 询" android:layout_marginTop="10dp" android:layout_marginLeft="80dp" android:layout_marginRight="160dp" android:textSize="21dp"/> <EditText android:layout_width="match_parent" android:layout_height="45dp" android:hint=" 起始站" android:textSize="20dp" android:background="@drawable/bg_edit" android:id="@+id/frag_et_start" android:layout_marginTop="45sp" android:layout_marginLeft="20dp" android:layout_marginRight="100dp" /> <EditText android:layout_width="match_parent" android:layout_height="45dp" android:hint=" 终点站" android:background="@drawable/bg_edit" android:textSize="20sp" android:id="@+id/frag_et_end" android:layout_marginTop="100dp" android:layout_marginLeft="20dp" android:layout_marginRight="100dp" /> <ImageButton android:id="@+id/frag_btn_find" android:layout_width="60dp" android:layout_height="60dp" android:layout_marginTop="70dp" android:layout_marginLeft="330dp" android:background="@mipmap/button_find" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="165dp" android:background="@color/gray" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/frag_recycle_show" android:layout_width="match_parent" android:layout_height="453dp" android:layout_marginTop="170dp" /> </FrameLayout>
fragment_left_list
<?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="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".fragment.frag2.LeftListFragment"> <!-- TODO: Update blank fragment layout --> <androidx.recyclerview.widget.RecyclerView android:id="@+id/frag_recycle_left" android:layout_width="105dp" android:layout_height="628dp" android:layout_margin="1dp" android:background="@drawable/bg_bg2" android:padding="3dp" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/frag_recycle_right" android:layout_width="308dp" android:layout_height="628dp" android:layout_marginLeft="105dp" android:layout_marginTop="1dp" android:layout_marginRight="1dp" android:background="@drawable/bg_bg3" android:padding="3dp" /> </FrameLayout>
fragment_map
<?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" android:background="@drawable/bg_bg1" tools:context=".fragment.frag3.MapFragment"> <!-- TODO: Update blank fragment layout --> <EditText android:id="@+id/map_et_1" android:layout_width="match_parent" android:layout_height="45dp" android:hint=" 输入站点" android:textSize="20dp" android:background="@drawable/bg_edit" android:layout_marginTop="67dp" android:layout_marginLeft="40dp" android:layout_marginRight="100dp" android:padding="1dp" /> <ImageButton android:id="@+id/map_btn_1" android:layout_width="60dp" android:layout_height="60dp" android:layout_marginTop="70dp" android:layout_marginLeft="330dp" android:background="@mipmap/button_find" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:background="@color/gray" android:layout_marginTop="150dp" /> <TextView android:id="@+id/map_tv_1" android:layout_width="match_parent" android:layout_height="48dp" android:layout_marginLeft="0dp" android:layout_marginTop="160dp" android:layout_marginRight="0dp" android:paddingLeft="40dp" android:background="@drawable/bg_bg3" android:text=" " android:textSize="30dp" /> <ImageView android:layout_width="match_parent" android:layout_height="395dp" android:layout_marginTop="215dp" android:src="@mipmap/pic_dite" /> </FrameLayout>
item_bottom
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:background="@color/teal_700" > <LinearLayout android:id="@+id/menu_ll_1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal"> <ImageView android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/menu_iv_1" android:src="@drawable/selector_search"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/menu_tv_1" android:textSize="20sp" android:text="查询"/> </LinearLayout> <LinearLayout android:id="@+id/menu_ll_2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal"> <ImageView android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/menu_iv_2" android:src="@drawable/selector_subway"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/menu_tv_2" android:textSize="20sp" android:text="站点"/> </LinearLayout> <LinearLayout android:id="@+id/menu_ll_3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal"> <ImageView android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/menu_iv_3" android:src="@drawable/selector_map"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/menu_tv_3" android:textSize="20sp" android:text="地图"/> </LinearLayout> </LinearLayout>
item_left_list
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="站点名" android:paddingLeft="10dp" android:paddingRight="10dp" android:textSize="20sp" android:id="@+id/item_left_station" android:layout_marginTop="2dp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/gray" android:layout_marginTop="2dp" /> </LinearLayout>
item_list_view
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/bg_bg3" android:padding="8dp" android:layout_marginTop="8dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginBottom="5dp"> <TextView android:id="@+id/list_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="起始站" android:textSize="18dp" android:textColor="@color/black" android:layout_marginTop="5dp" /> <TextView android:id="@+id/list_mid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="---" android:textSize="18dp" android:layout_toRightOf="@+id/list_1" android:textColor="@color/black" android:layout_marginTop="5dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" /> <TextView android:id="@+id/list_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:layout_toRightOf="@+id/list_mid" android:text="终点站" android:textSize="18dp" android:textColor="@color/black" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/gray" android:layout_below="@id/list_1" android:layout_marginTop="2dp"/> <TextView android:id="@+id/list_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18dp" android:layout_toRightOf="@id/list_2" android:layout_marginTop="5dp" android:text="经过站数" android:layout_marginLeft="20dp" android:textColor="@color/black" /> <TextView android:id="@+id/list_4" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/list_3" android:textSize="18dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:text="路线" android:textColor="@color/black" /> </RelativeLayout>
bottom_nav_menu
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_1" android:icon="@drawable/selector_search" android:title="查询" /> <item android:id="@+id/menu_2" android:icon="@drawable/selector_subway" android:title="站点" /> <item android:id="@+id/menu_3" android:icon="@drawable/selector_map" android:title="地图" /> </menu>