首页 > 其他分享 >地铁app

地铁app

时间:2023-06-11 11:34:46浏览次数:50  
标签:int app id cursor 地铁 line public android

 

package com.example.subway1;

import android.view.View;import android.widget.EditText;import android.widget.TextView;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import database.DBHelper;

import java.util.ArrayList;import java.util.List;

public class ByPointActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText et_Point;

    private TextView tv_showPoint;

    private DBHelper mHelper;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_by_point);

        et_Point=findViewById(R.id.et_Point);

        tv_showPoint=findViewById(R.id.tv_showPoint);

        findViewById(R.id.bt_ByPoint1).setOnClickListener(this);

    }

    protected void onStart() {

        super.onStart();

        mHelper=DBHelper.getInstance(this);

        mHelper.openWriteLink();

        mHelper.openReadLink();

    }

 

    @Override

    protected void onStop() {

        super.onStop();

        mHelper.closeLink();

    }

    @Override

    public void onClick(View view) {

        List<String> list=mHelper.find3(et_Point.getText().toString());

        StringBuffer buffer=new StringBuffer();

        if(list.size()==0){

            tv_showPoint.setText("没有结果");

        }else {

            for (int i=0;i<list.size();i++){

                buffer.append("线路:"+list.get(i)+"\n");

            }

            tv_showPoint.setText(buffer);

        }

    }

}

 

 

package com.example.subway1;

import android.content.Intent;import android.view.View;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        findViewById(R.id.bt_ByLine).setOnClickListener(this);

        findViewById(R.id.bt_ByPoint).setOnClickListener(this);

        findViewById(R.id.bt_extreme).setOnClickListener(this);

    }

 

    @Override

    public void onClick(View view) {

        switch (view.getId()){

            case R.id.bt_ByLine:

                startActivity(new Intent(this,ByLineActivity.class));

                break;

            case R.id.bt_ByPoint:

                startActivity(new Intent(this,ByPointActivity.class));

                break;

            case R.id.bt_extreme:

                startActivity(new Intent(this,ByExtremeActivity.class));

                break;

        }

    }

}

 

 

package database;

import android.content.Context;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;import java.util.ArrayList;import java.util.List;import entity.Line;

public class DBHelper extends SQLiteOpenHelper {

    private static final String DB_NAME="sub.db";

    private static final String TABLE_NAME="firstline";

    private static final String TABLE_NAME1="changeline";

    private static final int DB_VERSION=1;

    private static DBHelper mHelper=null;

    private SQLiteDatabase mRDB=null;

    private SQLiteDatabase mWDB=null;

    ArrayList<String> array=new ArrayList<String>();

 

    private DBHelper(Context context){

        super(context,DB_NAME,null,DB_VERSION);

    }

    public static DBHelper getInstance(Context context){

        if(mHelper==null)

        {

            mHelper=new DBHelper(context);

        }

        return mHelper;

    }

    public SQLiteDatabase openReadLink(){

        if(mRDB==null||!mRDB.isOpen())

        {

            mRDB=mHelper.getReadableDatabase();

        }

        return mRDB;

    }

    public SQLiteDatabase openWriteLink(){

        if(mWDB==null||!mWDB.isOpen())

        {

            mWDB=mHelper.getWritableDatabase();

        }

        return mWDB;

    }

    public void closeLink(){

        if(mRDB!=null&&mRDB.isOpen())

        {

            mRDB.close();

            mRDB=null;

        }

        if(mWDB!=null&&mWDB.isOpen())

        {

            mWDB.close();

            mWDB=null;

        }

    }

    @Override

    public void onCreate(SQLiteDatabase db) {

        String sql="CREATE TABLE IF NOT EXISTS "+TABLE_NAME+"("+

                " StopID VARCHAR NOT NULL,"+

                " StopName VARCHAR NOT NULL,"+

                " Line VARCHAR NOT NULL)";

        db.execSQL(sql);

        sql="CREATE TABLE IF NOT EXISTS "+TABLE_NAME1+"("+

                " ID1 VARCHAR NOT NULL,"+

                " ID2 VARCHAR NOT NULL,"+

                " ChangeStopName VARCHAR NOT NULL)";

        db.execSQL(sql);

    }

 

    @Override

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

 

    }

    public List<String> find3(String linepoint){

        List<String>list=new ArrayList<>();

        Cursor cursor=mRDB.query(TABLE_NAME,null,"StopName=?",new String[]{linepoint},null,null,null);

            while (cursor.moveToNext()) {

                String s=cursor.getString(2);

                list.add(s+" ");

            }

        return list;

    }

    public List<String> find1(String line){

        List<String>list=new ArrayList<>();

            Cursor cursor=mRDB.query(TABLE_NAME,null,"Line=?",new String[]{line},null,null,null);

            while (cursor.moveToNext()) {

                String s = cursor.getString(1);

                list.add(s);

            }

                return list;

            }

    public int CheckAll(Line line)  {

        int checkall=0;

        Cursor cursor=mRDB.rawQuery("SELECT * FROM firstline f1 JOIN firstline f2 on f1.Line=f2.Line WHERE f1.StopName=? AND f2.StopName=?",new String[]{line.getStartstopname(),line.getEndstopname()});

        while(cursor.moveToNext()){

            line.setTemporaryline(cursor.getInt(2));

        }

        if(line.getTemporaryline()!=0) {

            checkall=1;

            return checkall;

        }

        else if(line.getTemporaryline()==0){

            cursor=mRDB.rawQuery("select * from firstline where StopName='"+line.getStartstopname()+"' or StopName='"+line.getEndstopname()+"'",null);

            while(cursor.moveToNext()) {

                if(line.getStartstopname().equals(cursor.getString(1)))

                {

                    line.setOriginline(cursor.getInt(2));

                }

                if(line.getEndstopname().equals(cursor.getString(1))) {

                    line.setFinishline(cursor.getInt(2));

                }

            }

            if(line.getOriginline()==0||line.getFinishline()==0) {

                checkall=4;

                return checkall;

            }

            cursor=mRDB.rawQuery("select * from changeline where ID1='"+line.getOriginline()+"' and ID2='"+line.getFinishline()+"'",null);

            while(cursor.moveToNext()) {

                line.setMiddlestop(cursor.getString(2));

            }

            if(line.getMiddlestop().equals("")) {

                checkall=3;

                return checkall;

            }

            else {

                checkall=2;

                return checkall;

            }

        }

        return checkall;

 

    }

    public ArrayList<String> Connectonlyoneline(Line line)

    {

        ArrayList<String> array1=new ArrayList<String>();

        int c=0;

        try {

            Cursor cursor=mRDB.rawQuery("SELECT * FROM firstline f1 JOIN firstline f2 on f1.Line=f2.Line WHERE f1.StopName='"+line.getStartstopname()+"' AND f2.StopName='"+line.getEndstopname()+"'",null);

            while(cursor.moveToNext()) {

                line.setTemporaryline(cursor.getInt(2));

            }

            System.out.println(line.getTemporaryline());

            array.add(" 地铁"+line.getTemporaryline()+"号线");

            c=select(line);

            System.out.println(c);

            if(c==1)

            {

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array.add(cursor.getString(1));

                }

            }

            else if(c==2)

            {

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array1.add(cursor.getString(1));

                }

                for(int i=0;i<array1.size();i++)

                {

                    System.out.print(array1.get(i)+" ");

                }

                for(int j=array1.size()-1;j>=0;j--)

                {

                    array.add(array1.get(j));

                }

            }

        } catch (ClassNotFoundException e) {

            throw new RuntimeException(e);

        } finally {

            line.setArray(array);

            for(int i=0;i<array.size();i++) {

                System.out.println(array.get(i)+" ");

            }

        }

        return array;

    }

    public int select(Line line) throws ClassNotFoundException {

        int i=0;

        Cursor cursor=mRDB.rawQuery("select * from firstline where StopName='"+line.getStartstopname()+"'and Line='"+line.getTemporaryline()+"' or StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"'",null);

            while(cursor.moveToNext()) {

                if(line.getStartstopname().equals(cursor.getString(1)))

                {

                    line.setStartstopID(cursor.getInt(0));

                }

                if(line.getEndstopname().equals(cursor.getString(1))) {

                    line.setEndstopID(cursor.getInt(0));

                }

            }

        System.out.println(line.getStartstopID()+" "+line.getEndstopID());

        if(line.getStartstopID()<line.getEndstopID()) {

            i=1;

            return i;

        }

        else {

            i=2;

            return i;

        }

    }

    public ArrayList<String> Connecttwoline(Line line) throws ClassNotFoundException{

        int c=0;

        same(line);

        Cursor cursor=mRDB.rawQuery("select * from changeline where ID1='"+line.getOriginline()+"' and ID2='"+line.getFinishline()+"'",null);

        while(cursor.moveToNext()) {

            line.setMiddlestop(cursor.getString(2));

        }

        line.setTemporarystartstopname(line.getStartstopname());

        line.setTemporaryendstopname(line.getEndstopname());

        cursor=mRDB.rawQuery("select * from firstline where Line='"+line.getOriginline()+"' and StopName='"+line.getMiddlestop()+"'",null);

        while(cursor.moveToNext()) {

            line.setEndstopname(cursor.getString(1));

        }

        line.setStartstopname(line.getTemporarystartstopname());

        line.setTemporaryline(line.getOriginline());

        array.add("地铁"+line.getOriginline()+"号线");

        c=select(line);

        if(c==1)

        {

            cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

            while(cursor.moveToNext())

            {

                array.add(cursor.getString(1));

            }

        }

        else if(c==2)

        {

            ArrayList<String> array1=new ArrayList<String>();

            cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

            while(cursor.moveToNext())

            {

                array1.add(cursor.getString(1));

            }

            for(int i=0;i<array1.size();i++)

            {

                System.out.print(array1.get(i)+" ");

            }

            for(int j=array1.size()-1;j>=0;j--)

            {

                array.add(array1.get(j));

            }

        }

        array.add("换乘"+line.getFinishline()+"号线");

        line.setStartstopname(line.getMiddlestop());

        line.setEndstopname(line.getTemporaryendstopname());

        line.setTemporaryline(line.getFinishline());

        c=select(line);

        if(c==1)

        {

            cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

            while(cursor.moveToNext())

            {//���������

                array.add(cursor.getString(1));

            }

        }

        else if(c==2)

        {//��ʼվ��Ŵ����յ�վ������ʼվ�ں��յ�վ��ǰ

            ArrayList<String> array1=new ArrayList<String>();

            cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

            while(cursor.moveToNext())

            {

                array1.add(cursor.getString(1));

            }

            for(int i=0;i<array1.size();i++)

            {

                System.out.print(array1.get(i)+" ");

            }

            for(int j=array1.size()-1;j>=0;j--)

            {

                array.add(array1.get(j));

            }

        }

        return array;

 

    }

    public int same(Line line)  {

        int checksameline=0;

        Cursor cursor=mRDB.rawQuery("select * from firstline where StopName='"+line.getStartstopname()+"' or StopName='"+line.getEndstopname()+"'",null);

        while(cursor.moveToNext()) {

            if(line.getStartstopname().equals(cursor.getString(1)))

            {

                line.setOriginline(cursor.getInt(2));

            }

            if(line.getEndstopname().equals(cursor.getString(1))) {

                line.setFinishline(cursor.getInt(2));

            }

        }

        if(line.getFinishline()==line.getOriginline()) {//��ͬһ����

            checksameline=1;

            return checksameline;

        }

        else {//����ͬһ����

            checksameline=2;

            return checksameline;

        }

    }

    public ArrayList<String> Connectthreeline(Line line) throws ClassNotFoundException {

        ArrayList<Integer> array1=new ArrayList<Integer>();

        int c=0;

        int min=0;

        same(line);

        Cursor cursor=mRDB.rawQuery("SELECT    * FROM    changeline c1 JOIN changeline c2 ON c1.ID2 = c2.ID1 WHERE trim(c1.ChangeStopName) != '' AND trim(c2.ChangeStopName) != '' AND c1.ID1 = '"+line.getOriginline()+"' AND c2.ID2 = '"+line.getFinishline()+"'",null);

        while(cursor.moveToNext())

        {

            if(line.getOriginline()==cursor.getInt(0))

            {

                array1.add(cursor.getInt(1));

            }

        }

        line.setTemporarystartstopname(line.getStartstopname());

        line.setTemporaryendstopname(line.getEndstopname());

        for(int j=0;j<array1.size();j++)

        {

            ArrayList<String> array3=new ArrayList<String>();

 

            System.out.println("Ҳ����������Ҫ����ʼվ"+line.getTemporarystartstopname());

            cursor=mRDB.rawQuery("select * from changeline where ID1='"+line.getOriginline()+"' and ID2='"+array1.get(j)+"'",null);

            while(cursor.moveToNext())

            {

                line.setEndstopname(cursor.getString(2));

            }

            array3.add("����"+line.getOriginline()+"����");

            array3.add(line.getTemporarystartstopname());

            cursor=mRDB.rawQuery("SELECT * FROM firstline f1 JOIN firstline f2 on f1.Line=f2.Line WHERE f1.StopName='"+line.getStartstopname()+"' AND f2.StopName='"+line.getEndstopname()+"'",null);

            //��֤������תվ��ͬһ����·��

            while(cursor.moveToNext()) {

                line.setTemporaryline(cursor.getInt(2));

            }

            c=select(line);

            if(c==1)

            {

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {//���������

                    array3.add(cursor.getString(1));

                }

            }

            else if(c==2)

            {//��ʼվ��Ŵ����յ�վ������ʼվ�ں��յ�վ��ǰ

                ArrayList<String> array2=new ArrayList<String>();

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array2.add(cursor.getString(1));

                }

                for(int i=0;i<array2.size();i++)

                {//�����Ƿ���ֵ

                    System.out.print(array2.get(i)+" ");

                }

                for(int i=array2.size()-1;i>=0;i--)

                {//��վ��������                    array3.add(array2.get(i));

                }

            }

            line.setStartstopname(line.getEndstopname());

            cursor=mRDB.rawQuery("select * from changeline where ID1='"+array1.get(j)+"' and ID2='"+line.getFinishline()+"'",null);

            while(cursor.moveToNext())

            {

                line.setEndstopname(cursor.getString(2));

            }

            cursor=mRDB.rawQuery("SELECT * FROM firstline f1 JOIN firstline f2 on f1.Line=f2.Line WHERE f1.StopName='"+line.getStartstopname()+"' AND f2.StopName='"+line.getEndstopname()+"'",null);

            while(cursor.moveToNext()) {

                line.setTemporaryline(cursor.getInt(2));

            }

            array3.add("ת��"+line.getTemporaryline()+"����");

            c=select(line);

            if(c==1)

            {

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array3.add(cursor.getString(1));

                }

            }

            else if(c==2)

            {

                ArrayList<String> array2=new ArrayList<String>();

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array2.add(cursor.getString(1));

                }

                for(int i=0;i<array2.size();i++)

                {

                    System.out.print(array2.get(i)+" ");

                }

                for(int i=array2.size()-1;i>=0;i--)

                {

                    array3.add(array2.get(i));

                }

            }

            line.setStartstopname(line.getEndstopname());

            line.setEndstopname(line.getTemporaryendstopname());

            cursor=mRDB.rawQuery("SELECT * FROM firstline f1 JOIN firstline f2 on f1.Line=f2.Line WHERE f1.StopName='"+line.getStartstopname()+"' AND f2.StopName='"+line.getEndstopname()+"'",null);

            while(cursor.moveToNext()) {

                line.setTemporaryline(cursor.getInt(2));

            }

            array3.add("ת��"+line.getTemporaryline()+"����");

            c=select(line);

            if(c==1)

            {

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array3.add(cursor.getString(1));

                }

            }

            else if(c==2)

            {

                ArrayList<String> array2=new ArrayList<String>();

                cursor=mRDB.rawQuery("select * from firstline where StopID>=(select StopID from firstline where StopName='"+line.getEndstopname()+"' and Line='"+line.getTemporaryline()+"') and StopID<=(select StopID from firstline where StopName='"+line.getStartstopname()+"' and Line='"+line.getTemporaryline()+"')",null);

                while(cursor.moveToNext())

                {

                    array2.add(cursor.getString(1));

                }

                for(int i=0;i<array2.size();i++)

                {

                    System.out.print(array2.get(i)+" ");

                }

                for(int i=array2.size()-1;i>=0;i--)

                {

                    array3.add(array2.get(i));

                }

            }

            if(j==0) {

                min=array3.size();

            }

            System.out.println();

            System.out.println();

            for(int x=0;x<array3.size();x++) {

                System.out.print(array3.get(x)+" ");

 

            }

            System.out.println();

            System.out.println(min);

            if(min>=array3.size()) {

                min=array3.size();

                for(int x=0;x<array3.size();x++) {

                    System.out.print(array3.get(x)+" ");

 

                }

                array=array3;

            }

        }

 

        return array;

 

    }

}

 

 

package com.example.subway1;

import android.view.View;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import database.DBHelper;import entity.Line;

import java.sql.SQLException;import java.util.ArrayList;

public class ByExtremeActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText et_Star;

    private EditText et_Stop;

    private TextView tv_showExtreme;

    private DBHelper mHelper;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_by_extreme);

        et_Star=findViewById(R.id.et_Star);

        et_Stop=findViewById(R.id.et_Stop);

        tv_showExtreme=findViewById(R.id.tv_showExtreme);

        findViewById(R.id.bt_ByExtreme1).setOnClickListener(this);

    }

    protected void onStart() {

        super.onStart();

        mHelper=DBHelper.getInstance(this);

        mHelper.openWriteLink();

        mHelper.openReadLink();

    }

 

    @Override

    protected void onStop() {

        super.onStop();

        mHelper.closeLink();

    }

    @Override

    public void onClick(View view) {

        Line line = new Line();

        StringBuffer buffer=new StringBuffer();

        ArrayList<String> array = new ArrayList<String>();

        line.setStartstopname(et_Star.getText().toString());

        line.setEndstopname(et_Stop.getText().toString());

        int x = mHelper.CheckAll(line);

        buffer.append(x+"\n");

        tv_showExtreme.setText(buffer);

        buffer=new StringBuffer();

        if (x == 1) {

            array = mHelper.Connectonlyoneline(line);

        } else if (x == 2) {

            try {

                array = mHelper.Connecttwoline(line);

            } catch (ClassNotFoundException e) {

                throw new RuntimeException(e);

            }

        } else if (x == 3) {

            try {

                array = mHelper.Connectthreeline(line);

            } catch (ClassNotFoundException e) {

                throw new RuntimeException(e);

            }

        } else {

            Toast.makeText(this, "有错误", Toast.LENGTH_SHORT).show();

        }

        for (int i=0;i<array.size();i++){

            buffer.append(array.get(i)+"\n");

        }

        tv_showExtreme.setText(buffer);

    }

}

 

 

package com.example.subway1;

import android.view.View;import android.widget.EditText;import android.widget.TextView;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import database.DBHelper;

import java.util.ArrayList;import java.util.List;

public class ByPointActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText et_Point;

    private TextView tv_showPoint;

    private DBHelper mHelper;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_by_point);

        et_Point=findViewById(R.id.et_Point);

        tv_showPoint=findViewById(R.id.tv_showPoint);

        findViewById(R.id.bt_ByPoint1).setOnClickListener(this);

    }

    protected void onStart() {

        super.onStart();

        mHelper=DBHelper.getInstance(this);

        mHelper.openWriteLink();

        mHelper.openReadLink();

    }

 

    @Override

    protected void onStop() {

        super.onStop();

        mHelper.closeLink();

    }

    @Override

    public void onClick(View view) {

        List<String> list=mHelper.find3(et_Point.getText().toString());

        StringBuffer buffer=new StringBuffer();

        if(list.size()==0){

            tv_showPoint.setText("没有结果");

        }else {

            for (int i=0;i<list.size();i++){

                buffer.append("线路:"+list.get(i)+"\n");

            }

            tv_showPoint.setText(buffer);

        }

    }

}

 

 

package entity;

import java.util.ArrayList;

public class Line {

    private String startstopname;//��ʼվվ��

    private String endstopname;//����վվ��

    private int startstopID;//    ��ʼվվ���

    private int endstopID;//����վվ���

    private String startline1=null;//��ʼ��ĵ�һ����

    private String startline2=null;//��ʼ��ڶ�����

    private String endline1=null;//������ĵ�һ����

    private String endline2=null;//������ĵڶ�����

    private ArrayList<String> array = new ArrayList<String>();//��Ź���վ��

    private int originline;//��ʼվ������·

    private int finishline;//������������·

    private String middlestop;//��תվվ��

    private String temporarystartstopname;//��ʱ��ʼվ������

    private String temporaryendstopname;//��ʱ�յ�վ������

    private int temporaryline=0;//��ʱ��·

    public Line() {

 

    }

    public int getTemporaryline() {

        return temporaryline;

    }

    public void setTemporaryline(int temporaryline) {

        this.temporaryline = temporaryline;

    }

    public String getTemporarystartstopname() {

        return temporarystartstopname;

    }

    public void setTemporarystartstopname(String temporarystartstopname) {

        this.temporarystartstopname = temporarystartstopname;

    }

    public String getTemporaryendstopname() {

        return temporaryendstopname;

    }

    public void setTemporaryendstopname(String temporaryendstopname) {

        this.temporaryendstopname = temporaryendstopname;

    }

    public String getMiddlestop() {

        return middlestop;

    }

    public void setMiddlestop(String middlestop) {

        this.middlestop = middlestop;

    }

    public int getOriginline() {

        return originline;

    }

    public void setOriginline(int originline) {

        this.originline = originline;

    }

    public int getFinishline() {

        return finishline;

    }

    public void setFinishline(int finishline) {

        this.finishline = finishline;

    }

    public ArrayList<String> getArray() {

        return array;

    }

    public void setArray(ArrayList<String> array) {

        this.array = array;

    }

    public String getStartline1() {

        return startline1;

    }

    public void setStartline1(String startline1) {

        this.startline1 = startline1;

    }

    public String getStartline2() {

        return startline2;

    }

    public void setStartline2(String startline2) {

        this.startline2 = startline2;

    }

    public String getEndline1() {

        return endline1;

    }

    public void setEndline1(String endline1) {

        this.endline1 = endline1;

    }

    public String getEndline2() {

        return endline2;

    }

    public void setEndline2(String endline2) {

        this.endline2 = endline2;

    }

    public String getStartstopname() {

        return startstopname;

    }

    public void setStartstopname(String startstopname) {

        this.startstopname = startstopname;

    }

    public String getEndstopname() {

        return endstopname;

    }

    public void setEndstopname(String endstopname) {

        this.endstopname = endstopname;

    }

    public int getStartstopID() {

        return startstopID;

    }

    public void setStartstopID(int startstopID) {

        this.startstopID = startstopID;

    }

    public int getEndstopID() {

        return endstopID;

    }

    public void setEndstopID(int endstopID) {

        this.endstopID = endstopID;

    }

 

    @Override

    public String toString() {

        return "Line{" +

                "startstopname='" + startstopname + '\'' +

                ", endstopname='" + endstopname + '\'' +

                ", startstopID=" + startstopID +

                ", endstopID=" + endstopID +

                ", startline1='" + startline1 + '\'' +

                ", startline2='" + startline2 + '\'' +

                ", endline1='" + endline1 + '\'' +

                ", endline2='" + endline2 + '\'' +

                ", array=" + array +

                ", originline=" + originline +

                ", finishline=" + finishline +

                ", middlestop='" + middlestop + '\'' +

                ", temporarystartstopname='" + temporarystartstopname + '\'' +

                ", temporaryendstopname='" + temporaryendstopname + '\'' +

                ", temporaryline=" + temporaryline +

                '}';

    }

}

 

 

<?xml version="1.0" encoding="utf-8"?>

<ScrollView

        xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:tools="http://schemas.android.com/tools"

        xmlns:app="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        tools:context=".ByExtremeActivity"

        android:orientation="vertical"

>

    <LinearLayout android:layout_width="wrap_content"

                  android:layout_height="match_parent"

                  android:orientation="vertical">

    <LinearLayout android:layout_width="match_parent"

                  android:layout_height="wrap_content"

                  android:orientation="horizontal"

                  android:layout_marginTop="20dp"

    >

        <EditText android:layout_width="197dp"

                  android:layout_height="69dp"

                  android:layout_marginLeft="5dp"

                  android:id="@+id/et_Star"

        />

        <EditText android:layout_width="189dp"

                  android:layout_height="match_parent"

                  android:layout_marginLeft="10dp"

                  android:id="@+id/et_Stop"

 

        />

    </LinearLayout>

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="查询"

            android:id="@+id/bt_ByExtreme1"

    />

        <TextView android:layout_width="match_parent"

                  android:layout_height="wrap_content"

                  android:id="@+id/tv_showExtreme"

                  android:layout_below="@id/bt_ByExtreme1"

                  android:textColor="@color/black"

                  android:textSize="20sp"

        />

    </LinearLayout>

 

 

</ScrollView>

 

 

<?xml version="1.0" encoding="utf-8"?>

<ScrollView

        xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:tools="http://schemas.android.com/tools"

        xmlns:app="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        tools:context=".ByLineActivity"

        android:orientation="vertical"

>

    <LinearLayout android:layout_width="match_parent"

                  android:layout_height="wrap_content"

                  android:orientation="vertical"

    >

    <EditText android:layout_width="match_parent"

              android:layout_height="wrap_content"

              android:id="@+id/et_Line"

              />

 

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="查询"

            android:id="@+id/bt_ByLine1"

    />

 

        <TextView android:layout_width="match_parent"

                  android:layout_height="wrap_content"

                  android:id="@+id/tv_showLine"

                  android:layout_below="@id/bt_ByLine1"

                  android:textColor="@color/black"

                  android:textSize="20sp"

        />

    </LinearLayout>

 

</ScrollView>

 

 

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

        xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:tools="http://schemas.android.com/tools"

        xmlns:app="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        tools:context=".ByPointActivity"

        android:orientation="vertical"

>

    <EditText android:layout_width="match_parent"

              android:layout_height="wrap_content"

              android:id="@+id/et_Point"

              android:layout_marginTop="5dp"

    />

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="查询"

            android:id="@+id/bt_ByPoint1"

    />

        <TextView android:layout_width="match_parent"

                  android:layout_height="wrap_content"

                  android:id="@+id/tv_showPoint"

                  android:layout_below="@id/bt_ByPoint1"

                  android:textColor="@color/black"

                  android:textSize="20sp"

        />

 

 

 

 

</LinearLayout>

 

 

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

        xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:tools="http://schemas.android.com/tools"

        xmlns:app="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        tools:context=".MainActivity"

        android:orientation="vertical"

>

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="按线路查询"

            android:layout_marginTop="200dp"

            android:id="@+id/bt_ByLine"

    />

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="站点查询"

            android:layout_marginTop="10dp"

            android:id="@+id/bt_ByPoint"

    />

    <Button android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="起点,终点查询"

            android:layout_marginTop="10dp"

            android:id="@+id/bt_extreme"

    />

 

 

</LinearLayout>

 

标签:int,app,id,cursor,地铁,line,public,android
From: https://www.cnblogs.com/zzfdbk/p/17472709.html

相关文章

  • 打卡app
     package entity;public class Day{    public StringgetKeyword(){        return keyword;    }     public void setKeyword(Stringkeyword){        this.keyword=keyword;    }     public Stringkeyword......
  • Apple设备_资料收藏
    苹果Mac操作系统下怎么显示隐藏文件(shift+cmmand+.)Mac清理-柠檬清理iPhone如何设置语音激活siri?嘿hey,Siri“嘿,Siri”是怎么实现的?macmini2018技术参数macmini2014技术参数作者:CH520......
  • application.properties的数据源配置
    #驱动类名称spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver#数据库连接的urlspring.datasource.url=jdbc:mysql://localhost:3306/tlias?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC#连接数据库的用户名spring.datasource.username=......
  • 02每日打卡APP
    02每日打卡APP2023.6.10第一阶段目标:1、用户注册:用户注册信息包括用户ID(学号)、用户名(姓名),手机号码,用户单位(班级),用户班级四项基本信息,用户第一次注册后,用户姓名不用每次输入 。2、每日总结打卡:内容包括:日期、每日关键字、每日总结、坚持天数(自动计数,显示上次天数)、连续最长天......
  • 03地铁查询系统
    地铁查询系统2023.6.101、优化返回两个站点之间最短路径功能:成为一个类,进行单元测试。2、生成遍历车站类:要求尽可能快地遍历地铁的所有车站呢(只用经过一次,不用下车,就算经过车站)。  连接数据库:packagecom.example.underground; importjava.sql.Connection;importja......
  • JS bind & apply/call
    bindletboundFunc=func.bind(context);将func的context修改为传入的参数,返回一个新的func函数callfunc.call(context,arg1,arg2,...)applyfunc.apply(context,args)call和apply之间唯一的语法区别是,call期望一个参数列表,而apply期望一个包含这些参数的......
  • My First CRUD App With Fast API
    ImagebyauthorIt’sthedaybeforemyfastAPIlivestream.Idecidedtocreateaguideforthestreamandturnitintoablogpost.So,hereitis.Streamstructure:FastAPIvsDjangoInstallationCreateFirstAPP&RouteSwaggerUIPathParamete......
  • uniapp-黑马优选学习01
    01.IDE使用HBuilderX02.scss/sass插件安装:为了方便样式的编写   地址: https://ext.dcloud.net.cn/plugin?name=compile-node-sass03.快捷键方案的设置、IDE主题色的设置、基本设置(ctlr加alt加逗号 :  ctrl+alt+, )    >>其它基本......
  • application.properties
    server.port=8080spring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3307/teachmanger?useSSL=falsespring.datasource.username=rootspring.datasource.password=123456spring.datasource.type=com.alibaba.dru......
  • mapper层
    AnswerMapper.xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTDMapper3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="co......