fixed ui elements
This commit is contained in:
		
							parent
							
								
									ed6927b7db
								
							
						
					
					
						commit
						e029609918
					
				
					 4 changed files with 103 additions and 62 deletions
				
			
		| 
						 | 
				
			
			@ -8,63 +8,3 @@ import android.view.View;
 | 
			
		|||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
 | 
			
		||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ServicesHolder> {
 | 
			
		||||
 | 
			
		||||
    private Service[] services;
 | 
			
		||||
 | 
			
		||||
    // Provide a reference to the views for each data item
 | 
			
		||||
    // Complex data items may need more than one view per item, and
 | 
			
		||||
    // you provide access to all the views for a data item in a view holder
 | 
			
		||||
 | 
			
		||||
    // Provide a suitable constructor (depends on the kind of dataset)
 | 
			
		||||
    public MyAdapter(Service[] services) {
 | 
			
		||||
        this.services = services;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create new views (invoked by the layout manager)
 | 
			
		||||
    @NonNull
 | 
			
		||||
    @Override
 | 
			
		||||
    public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
			
		||||
        View v = LayoutInflater.from(parent.getContext())
 | 
			
		||||
                .inflate(R.layout.list_item, parent, false);
 | 
			
		||||
        ServicesHolder vh = new ServicesHolder(v);
 | 
			
		||||
        return vh;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Replace the contents of a view (invoked by the layout manager)
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onBindViewHolder(ServicesHolder holder, int position) {
 | 
			
		||||
        Service service = services[position];
 | 
			
		||||
        holder.name.setText(service.getName());
 | 
			
		||||
        holder.rate.setText(""+service.getRate());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Return the size of your dataset (invoked by the layout manager)
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getItemCount() {
 | 
			
		||||
        return services.length;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    class ServicesHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
 | 
			
		||||
 | 
			
		||||
        TextView name;
 | 
			
		||||
        TextView rate;
 | 
			
		||||
 | 
			
		||||
        public ServicesHolder(View row){
 | 
			
		||||
            super(row);
 | 
			
		||||
            name = row.findViewById(R.id.Name);
 | 
			
		||||
            rate = row.findViewById(R.id.Rate);
 | 
			
		||||
            row.setOnClickListener(this);
 | 
			
		||||
        }
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onClick(View view) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,15 @@
 | 
			
		|||
package com.uottawa.olympus.olympusservices;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.support.annotation.NonNull;
 | 
			
		||||
import android.support.v4.app.DialogFragment;
 | 
			
		||||
import android.support.v7.app.AppCompatActivity;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.v7.widget.LinearLayoutManager;
 | 
			
		||||
import android.support.v7.widget.RecyclerView;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.AdapterView;
 | 
			
		||||
import android.widget.ArrayAdapter;
 | 
			
		||||
import android.widget.GridView;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +43,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
 | 
			
		|||
        mLayoutManager = new LinearLayoutManager(this);
 | 
			
		||||
        mRecyclerView.setLayoutManager(mLayoutManager);
 | 
			
		||||
 | 
			
		||||
        mAdapter = new MyAdapter(services);
 | 
			
		||||
        mAdapter = new MyAdapter(services, this);
 | 
			
		||||
        mRecyclerView.setAdapter(mAdapter);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -88,4 +92,68 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
 | 
			
		|||
        this.recreate();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ServicesHolder> {
 | 
			
		||||
 | 
			
		||||
        private Service[] services;
 | 
			
		||||
        private Context context;
 | 
			
		||||
 | 
			
		||||
        // Provide a reference to the views for each data item
 | 
			
		||||
        // Complex data items may need more than one view per item, and
 | 
			
		||||
        // you provide access to all the views for a data item in a view holder
 | 
			
		||||
 | 
			
		||||
        // Provide a suitable constructor (depends on the kind of dataset)
 | 
			
		||||
        public MyAdapter(Service[] services, Context context) {
 | 
			
		||||
            this.services = services;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Create new views (invoked by the layout manager)
 | 
			
		||||
        @NonNull
 | 
			
		||||
        @Override
 | 
			
		||||
        public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
			
		||||
            View v = LayoutInflater.from(parent.getContext())
 | 
			
		||||
                    .inflate(R.layout.list_item, parent, false);
 | 
			
		||||
            ServicesHolder vh = new ServicesHolder(v);
 | 
			
		||||
            return vh;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Replace the contents of a view (invoked by the layout manager)
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onBindViewHolder(ServicesHolder holder, int position) {
 | 
			
		||||
            Service service = services[position];
 | 
			
		||||
            holder.name.setText(service.getName());
 | 
			
		||||
            holder.rate.setText(""+service.getRate());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Return the size of your dataset (invoked by the layout manager)
 | 
			
		||||
        @Override
 | 
			
		||||
        public int getItemCount() {
 | 
			
		||||
            return services.length;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        class ServicesHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
 | 
			
		||||
 | 
			
		||||
            TextView name;
 | 
			
		||||
            TextView rate;
 | 
			
		||||
 | 
			
		||||
            public ServicesHolder(View row){
 | 
			
		||||
                super(row);
 | 
			
		||||
                name = row.findViewById(R.id.Name);
 | 
			
		||||
                rate = row.findViewById(R.id.Rate);
 | 
			
		||||
                row.setOnClickListener(this);
 | 
			
		||||
            }
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onClick(View view) {
 | 
			
		||||
                editService(view);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,38 @@
 | 
			
		|||
        android:textSize="20sp"
 | 
			
		||||
        android:layout_marginTop="10dp"
 | 
			
		||||
        app:fontFamily="@font/julius_sans_one" />
 | 
			
		||||
 | 
			
		||||
    <LinearLayout
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:orientation="horizontal"
 | 
			
		||||
        android:paddingBottom="10dp">
 | 
			
		||||
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/Title1"
 | 
			
		||||
            android:layout_width="300dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_marginBottom="5dp"
 | 
			
		||||
            android:layout_marginTop="10dp"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:text="Name"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
 | 
			
		||||
            android:textColor="@android:color/white"
 | 
			
		||||
            android:textSize="15sp" />
 | 
			
		||||
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/Title2"
 | 
			
		||||
            android:layout_width="300dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_marginBottom="5dp"
 | 
			
		||||
            android:layout_marginTop="10dp"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:text="Rate"
 | 
			
		||||
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
 | 
			
		||||
            android:textColor="@android:color/white"
 | 
			
		||||
            android:textSize="15sp" />
 | 
			
		||||
    </LinearLayout>
 | 
			
		||||
 | 
			
		||||
    <LinearLayout
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
<?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="match_parent">
 | 
			
		||||
    android:layout_height="50dp"
 | 
			
		||||
    android:clickable="true">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue