Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.silvaggio.tracker;
- import java.lang.reflect.Array;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import android.annotation.SuppressLint;
- import android.content.Context;
- import android.content.Intent;
- import android.content.res.Resources;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.annotation.Nullable;
- import android.support.v4.app.Fragment;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.AdapterView;
- import android.widget.BaseAdapter;
- import android.widget.ListView;
- import android.widget.TextView;
- import android.widget.Toast;
- public class ViewWrits extends Fragment {
- ListView l;
- ArrayList<SingleWrit> list;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.view_writs, container, false);
- l = (ListView) view.findViewById(R.id.listWrits);
- Log.e("John" , "Loaded");
- l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
- long arg3) {
- Log.e("John", "LIST CLICKED") ;
- for(int i=0;i<list.size();i++){
- if(arg2 == i){
- SingleWrit data = list.get(i);
- String name = data.PlaintiffName;
- String address = data.PlaintiffStreet;
- Log.e("John", address);
- Toast.makeText(getActivity(),name+"\n"+address,Toast.LENGTH_LONG).show();
- Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
- Uri.parse("google.navigation:q="+address));
- startActivity(intent);
- }
- }
- // Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
- // Uri.parse("google.navigation:q=96 Harrington Avenue, Warwick"));
- // startActivity(intent);
- }
- });
- l.setAdapter(new WritAdapter(getActivity()));
- return view;
- }
- class SingleWrit
- {
- String PlaintiffName;
- String PlaintiffStreet;
- String PlaintiffCityState;
- String DefendantName;
- String DefendantStreet;
- String DefendantCityState;
- SingleWrit(String PlaintiffName,String PlaintiffStreet,String PlaintiffCityState,String DefendantName, String DefendantStreet,String DefendantCityState)
- {
- this.PlaintiffName=PlaintiffName;
- this.PlaintiffStreet=PlaintiffStreet;
- this.PlaintiffCityState=PlaintiffCityState;
- this.DefendantName=DefendantName;
- this.DefendantStreet=DefendantStreet;
- this.DefendantCityState=DefendantCityState;
- }
- }
- class WritAdapter extends BaseAdapter {
- // ArrayList<SingleWrit> list;
- Context context;
- WritAdapter(Context c)
- {
- context=c;
- list=new ArrayList<SingleWrit>();
- Resources res=c.getResources();
- String[] PlaintiffName=res.getStringArray(R.array.PlaintiffName);
- String[] PlaintiffStreet=res.getStringArray(R.array.PlaintiffStreet);
- String[] PlaintiffCityState=res.getStringArray(R.array.PlaintiffCityState);
- String[] DefendantName=res.getStringArray(R.array.DefendantName);
- String[] DefendantStreet=res.getStringArray(R.array.DefendantStreet);
- String[] DefendantCityState=res.getStringArray(R.array.DefendantCityState);
- for(int i=0;i<6;i++)
- {
- list.add(new SingleWrit(PlaintiffName[i],PlaintiffStreet[i],PlaintiffCityState[i],DefendantName[i],DefendantStreet[i],DefendantCityState[i]));
- }
- }
- @Override
- public int getCount() {
- return list.size();
- }
- @Override
- public Object getItem(int position) {
- return list.get(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @SuppressLint("ViewHolder") @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View row=inflater.inflate(R.layout.single_writview,parent,false);
- TextView PlaintiffName=(TextView) row.findViewById(R.id.textPlaintiffName);
- TextView PlaintiffStreet=(TextView) row.findViewById(R.id.textPlaintiffStreet);
- TextView PlaintiffCityState=(TextView) row.findViewById(R.id.textPlaintiffCityState);
- TextView DefendantName=(TextView) row.findViewById(R.id.textDefendantName);
- TextView DefendantStreet=(TextView) row.findViewById(R.id.textDefendantStreet);
- TextView DefendantCityState=(TextView) row.findViewById(R.id.textDefendantCityState);
- SingleWrit temp=list.get(position);
- PlaintiffName.setText(temp.PlaintiffName);
- PlaintiffStreet.setText(temp.PlaintiffStreet);
- PlaintiffCityState.setText(temp.PlaintiffCityState);
- DefendantName.setText(temp.DefendantName);
- DefendantStreet.setText(temp.DefendantStreet);
- DefendantCityState.setText(temp.DefendantCityState);
- return row;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment