Click here to Skip to main content
14,983,300 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Unable to open the drop down details in spinner.

What I have tried:

<pre>package edu.orangecoastcollege.cs273.occcoursefinder;

import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.Toast;

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

public class CourseSearchActivity extends AppCompatActivity  {

    private DBHelper db;
    private List<Course> allCoursesList;
    private List<Offering> allOfferingsList;
    private List<Offering> filteredOfferingsList;

    private EditText courseTitleEditText;
    private Spinner ok;
    private ListView offeringsListView;

    private OfferingListAdapter offeringListAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_course_search);

        deleteDatabase(DBHelper.DATABASE_NAME);
        db = new DBHelper(this);
        db.importCoursesFromCSV("courses.csv");

        db.importOfferingsFromCSV("offerings.csv");

        allOfferingsList = db.getAllOfferings();
        filteredOfferingsList = new ArrayList<>(allOfferingsList);

        allCoursesList = db.getAllCourses();

        courseTitleEditText = (EditText) findViewById(R.id.courseTitleEditText);
        courseTitleEditText.addTextChangedListener(courseTitleTextWatcher);

        ok = (Spinner) findViewById(R.id.ok);


        offeringListAdapter = new OfferingListAdapter(this, R.layout.offering_list_item, filteredOfferingsList);

        ok.setAdapter(offeringListAdapter);
        ArrayAdapter<String> instructorSpinnerAdapter = new ArrayAdapter<String>
                (this, android.R.layout.simple_spinner_item, getAllInstructorNames());
       //ok.setAdapter(instructorSpinnerAdapter);
      // ok.setOnItemSelectedListener(instructorSpinnerListener);


    }
    private String[] getAllInstructorNames(){
        String[] instructorNames = new String[allCoursesList.size() + 1];
        instructorNames[0] = "[Select Course]";
        for(int i = 1; i < instructorNames.length; i++){
            instructorNames[i] = allCoursesList.get(i - 1).getTitle();
        }
        return instructorNames;
    }

    public TextWatcher courseTitleTextWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            String input = charSequence.toString().toLowerCase();
            if (input.equals("")) {

            } else {
                String name = ok.getSelectedItem().toString();
                //Toast.makeText(CourseSearchActivity.this, name, Toast.LENGTH_SHORT).show();
               offeringListAdapter.clear();
                for (Offering offering : allOfferingsList) {
                    // If the course title starts with the user input,
                    // add it to the listAdapter
                   Course course = offering.getCourse();
                    if (course.getTitle().toLowerCase().contains(input))
                        offeringListAdapter.add(offering);
                }
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {


        }
    };
    public AdapterView.OnItemSelectedListener instructorSpinnerListener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            String selectedInstructorName = adapterView.getItemAtPosition(i).toString();
            if(selectedInstructorName.equals("[Select Instructor]")){
                offeringListAdapter.clear();
                for (Offering offering : allOfferingsList)
                    offeringListAdapter.add(offering);
            }
            else{
                offeringListAdapter.clear();

                }
            }


        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            adapterView.setSelection(0);
            Toast.makeText(getApplicationContext(), "Why?", Toast.LENGTH_SHORT).show();
        }
    };

    public void reset(View view){
        courseTitleEditText.setText("");
        ok.setSelection(0);
    }

}
package edu.orangecoastcollege.cs273.occcoursefinder;

/**
 * The <code>Course</code> class represents a single course at Orange Coast College,
 * including its alpha (e.g. CS), number (e.g. A273) and title (e.g. Mobile Application Development)
 *
 * @author Michael Paulding
 */
public class Course {
    private int mId;
    private String mAlpha;
    private String mNumber;
    private String mTitle;

    public Course(int id, String alpha, String number, String title) {
        mId = id;
        mAlpha = alpha;
        mNumber = number;
        mTitle = title;
    }

    public Course(String alpha, String number, String title) {
        this(-1, alpha, number, title);
    }

    public int getId() {
        return mId;
    }

    public String getAlpha() {
        return mAlpha;
    }

    public void setAlpha(String alpha) {
        mAlpha = alpha;
    }

    public String getNumber() {
        return mNumber;
    }

    public String getFullName() {
        return mAlpha + " " + mNumber;
    }

    public void setNumber(String number) {
        mNumber = number;
    }

    public String getTitle() {
        return mTitle;
    }

    public void setTitle(String title) {
        mTitle = title;
    }

    @Override
    public String toString() {
        return "Course{" +
                "Id=" + mId +
                ", Alpha='" + mAlpha + '\'' +
                ", Number='" + mNumber + '\'' +
                ", Title='" + mTitle + '\'' +
                '}';
    }
}
package edu.orangecoastcollege.cs273.occcoursefinder;

import android.content.ContentValues;
import android.content.Context;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

class DBHelper extends SQLiteOpenHelper {

    private Context mContext;

    //TASK: DEFINE THE DATABASE VERSION AND NAME  (DATABASE CONTAINS MULTIPLE TABLES)
    static final String DATABASE_NAME = "OCC";
    private static final int DATABASE_VERSION = 1;

    //TASK: DEFINE THE FIELDS (COLUMN NAMES) FOR THE COURSES TABLE
    public static final String COURSES_TABLE = "Courses";
    public static final String COURSES_KEY_FIELD_ID = "_id";
    public static final String FIELD_ALPHA = "alpha";
    public static final String FIELD_NUMBER = "number";
    public static final String FIELD_TITLE = "title";

    //TASK: DEFINE THE FIELDS (COLUMN NAMES) FOR THE INSTRUCTORS TABLE


    //TASK: DEFINE THE FIELDS (COLUMN NAMES) FOR THE OFFERINGS TABLE
    private static final String OFFERINGS_TABLE = "Offerings";
    private static final String OFFERINGS_KEY_FIELD_ID = "crn";
    private static final String FIELD_SEMESTER_CODE = "semester_code";
    public static final String FIELD_COURSE_ID = "course_id";

    public DBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase database) {
        String createQuery = "CREATE TABLE " + COURSES_TABLE + "("
                + COURSES_KEY_FIELD_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                + FIELD_ALPHA + " TEXT, "
                + FIELD_NUMBER + " TEXT, "
                + FIELD_TITLE + " TEXT" + ")";
        database.execSQL(createQuery);



        createQuery = "CREATE TABLE " + OFFERINGS_TABLE + "("
                + OFFERINGS_KEY_FIELD_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                + FIELD_SEMESTER_CODE + " INTEGER, "
                + FIELD_COURSE_ID + " INTEGER, "

                + "FOREIGN KEY(" + FIELD_COURSE_ID + ") REFERENCES "

                +  COURSES_TABLE + "(" + COURSES_KEY_FIELD_ID + ")" +
                ")";
        database.execSQL(createQuery);
    }

    @Override
    public void onUpgrade(SQLiteDatabase database,
                          int oldVersion,
                          int newVersion) {
        database.execSQL("DROP TABLE IF EXISTS " + COURSES_TABLE);

        database.execSQL("DROP TABLE IF EXISTS " + OFFERINGS_TABLE);
        onCreate(database);
    }

    //********** COURSE TABLE OPERATIONS:  ADD, GETALL, EDIT, DELETE

    public void addCourse(Course course) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put(FIELD_ALPHA, course.getAlpha());
        values.put(FIELD_NUMBER, course.getNumber());
        values.put(FIELD_TITLE, course.getTitle());

        db.insert(COURSES_TABLE, null, values);

        // CLOSE THE DATABASE CONNECTION
        db.close();
    }

    public ArrayList<Course> getAllCourses() {
        ArrayList<Course> coursesList = new ArrayList<>();
        SQLiteDatabase database = this.getReadableDatabase();
        //Cursor cursor = database.rawQuery(queryList, null);
        Cursor cursor = database.query(
                COURSES_TABLE,
                new String[]{COURSES_KEY_FIELD_ID, FIELD_ALPHA, FIELD_NUMBER, FIELD_TITLE},
                null,
                null,
                null, null, null, null);

        //COLLECT EACH ROW IN THE TABLE
        if (cursor.moveToFirst()) {
            do {
                Course course =
                        new Course(cursor.getInt(0),
                                cursor.getString(1),
                                cursor.getString(2),
                                cursor.getString(3));
                coursesList.add(course);
            } while (cursor.moveToNext());
        }
        return coursesList;
    }

    public void deleteCourse(Course course) {
        SQLiteDatabase db = this.getWritableDatabase();

        // DELETE THE TABLE ROW
        db.delete(COURSES_TABLE, COURSES_KEY_FIELD_ID + " = ?",
                new String[]{String.valueOf(course.getId())});
        db.close();
    }

    public void deleteAllCourses() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(COURSES_TABLE, null, null);
        db.close();
    }

    public void updateCourse(Course course) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put(FIELD_ALPHA, course.getAlpha());
        values.put(FIELD_NUMBER, course.getNumber());
        values.put(FIELD_TITLE, course.getTitle());

        db.update(COURSES_TABLE, values, COURSES_KEY_FIELD_ID + " = ?",
                new String[]{String.valueOf(course.getId())});
        db.close();
    }

    public Course getCourse(int id) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.query(
                COURSES_TABLE,
                new String[]{COURSES_KEY_FIELD_ID, FIELD_ALPHA, FIELD_NUMBER, FIELD_TITLE},
                COURSES_KEY_FIELD_ID + "=?",
                new String[]{String.valueOf(id)},
                null, null, null, null);

        if (cursor != null)
            cursor.moveToFirst();

        Course course = new Course(
                cursor.getInt(0),
                cursor.getString(1),
                cursor.getString(2),
                cursor.getString(3));

        db.close();
        return course;
    }




    //********** OFFERING TABLE OPERATIONS:  ADD, GETALL, EDIT, DELETE

    public void addOffering(int crn, int semesterCode, int courseId) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put(OFFERINGS_KEY_FIELD_ID, crn);
        values.put(FIELD_SEMESTER_CODE, semesterCode);
        values.put(FIELD_COURSE_ID, courseId);


        db.insert(OFFERINGS_TABLE, null, values);

        // CLOSE THE DATABASE CONNECTION
        db.close();
    }

    public ArrayList<Offering> getAllOfferings() {
        ArrayList<Offering> offeringsList = new ArrayList<>();
        SQLiteDatabase database = this.getReadableDatabase();
        //Cursor cursor = database.rawQuery(queryList, null);
        Cursor cursor = database.query(
                OFFERINGS_TABLE,
                new String[]{OFFERINGS_KEY_FIELD_ID, FIELD_SEMESTER_CODE, FIELD_COURSE_ID},
                null,
                null,
                null, null, null, null);

        //COLLECT EACH ROW IN THE TABLE
        if (cursor.moveToFirst()) {
            do {
                Course course = getCourse(cursor.getInt(2));
                //Instructor instructor = getInstructor(cursor.getInt(3));
                Offering offering = new Offering(cursor.getInt(0),
                        cursor.getInt(1), course);

                offeringsList.add(offering);
            } while (cursor.moveToNext());
        }
        return offeringsList;
    }

    public void deleteOffering(Offering offering) {
        SQLiteDatabase db = this.getWritableDatabase();

        // DELETE THE TABLE ROW
        db.delete(OFFERINGS_TABLE, OFFERINGS_KEY_FIELD_ID + " = ?",
                new String[]{String.valueOf(offering.getCRN())});
        db.close();
    }

    public void deleteAllOfferings() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(OFFERINGS_TABLE, null, null);
        db.close();
    }

    public void updateOffering(Offering offering) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put(FIELD_SEMESTER_CODE, offering.getSemesterCode());
        values.put(FIELD_COURSE_ID, offering.getCourse().getId());


        db.update(OFFERINGS_TABLE, values, OFFERINGS_KEY_FIELD_ID + " = ?",
                new String[]{String.valueOf(offering.getCRN())});
        db.close();
    }

    public Offering getOffering(int crn) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.query(
                OFFERINGS_TABLE,
                new String[]{OFFERINGS_KEY_FIELD_ID, FIELD_SEMESTER_CODE, FIELD_COURSE_ID},
                OFFERINGS_KEY_FIELD_ID + "=?",
                new String[]{String.valueOf(crn)},
                null, null, null, null);

        if (cursor != null)
            cursor.moveToFirst();

        Course course = getCourse(cursor.getInt(2));
        //Instructor instructor = getInstructor(cursor.getInt(3));
        Offering offering = new Offering(cursor.getInt(0),
                cursor.getInt(1), course);


        db.close();
        return offering;
    }

    public Cursor getAllLabelsAsCursor() {
        String[] columns = new String[]{"rowid AS _id, *"}; // Need _id column for SimpleCursorAdapter
        return this.getWritableDatabase().query(COURSES_TABLE,columns,null,null,null,null,null);
    }



    public boolean importCoursesFromCSV(String csvFileName) {
        AssetManager manager = mContext.getAssets();
        InputStream inStream;
        try {
            inStream = manager.open(csvFileName);
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }

        BufferedReader buffer = new BufferedReader(new InputStreamReader(inStream));
        String line;
        try {
            while ((line = buffer.readLine()) != null) {
                String[] fields = line.split(",");
                if (fields.length != 4) {
                    Log.d("OCC Course Finder", "Skipping Bad CSV Row: " + Arrays.toString(fields));
                    continue;
                }
                int id = Integer.parseInt(fields[0].trim());
                String alpha = fields[1].trim();
                String number = fields[2].trim();
                String title = fields[3].trim();
                addCourse(new Course(id, alpha, number, title));
            }
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }



    public boolean importOfferingsFromCSV(String csvFileName) {
        AssetManager am = mContext.getAssets();
        InputStream inStream = null;
        try {
            inStream = am.open(csvFileName);
        } catch (IOException e) {
            e.printStackTrace();
        }

        BufferedReader buffer = new BufferedReader(new InputStreamReader(inStream));
        String line;
        try {
            while ((line = buffer.readLine()) != null) {
                String[] fields = line.split(",");
                if (fields.length != 4) {
                    Log.d("OCC Course Finder", "Skipping Bad CSV Row: " + Arrays.toString(fields));
                    continue;
                }
                int crn = Integer.parseInt(fields[0].trim());
                int semesterCode = Integer.parseInt(fields[1].trim());
                int courseId = Integer.parseInt(fields[2].trim());

                addOffering(crn, semesterCode, courseId);
            }
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
package edu.orangecoastcollege.cs273.occcoursefinder;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Spinner;
import java.util.ArrayList;
import java.util.List;

/**
 * Helper class to provide custom adapter for the <code>Offering</code> list.
 */
public class OfferingListAdapter extends ArrayAdapter<Offering> {

    private Context mContext;
    private List<Offering> mOfferingsList = new ArrayList<>();
    private int mResourceId;

    /**
     * Creates a new <code>OfferingListAdapter</code> given a mContext, resource id and list of offerings.
     *
     * @param c The mContext for which the adapter is being used (typically an activity)
     * @param rId The resource id (typically the layout file name)
     * @param offerings The list of offerings to display
     */
    public OfferingListAdapter(Context c, int rId, List<Offering> offerings) {
        super(c, rId, offerings);
        mContext = c;
        mResourceId = rId;
        mOfferingsList = offerings;
    }

    /**
     * Gets the view associated with the layout.
     * @param pos The position of the Offering selected in the list.
     * @param convertView The converted view.
     * @param parent The parent - ArrayAdapter
     * @return The new view with all content set.
     */

    @Override
    public View getView(int pos, View convertView, ViewGroup parent)
    {
        final Offering selectedOffering = mOfferingsList.get(pos);
        final Course selectedCourse = selectedOffering.getCourse();


        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(mResourceId, null);
      //  LinearLayout offeringListLinearLayout = (LinearLayout) view.findViewById(R.id.offeringListLinearLayout);
        TextView offeringListFullNameTextView = (TextView) view.findViewById(R.id.offeringListFullNameTextView);
        Spinner spinner=(Spinner) convertView.findViewById(R.id.ok);
       // TextView offeringListTitleTextView = (TextView) view.findViewById(R.id.offeringListTitleTextView);
        //TextView offeringListCrnTextView = (TextView) view.findViewById(R.id.offeringListCrnTextView);

        //TODO:  Make a reference to the offeringListCRNTextView and set the text accordingly.

       // offeringListLinearLayout.setTag(selectedOffering);
        offeringListFullNameTextView.setText( selectedCourse.getTitle());

       // offeringListCrnTextView.setText(String.valueOf(selectedOffering.getCRN()));

        String[] colors={"Red","Green","Blue"};




        return view;
    }
}
package edu.orangecoastcollege.cs273.occcoursefinder;

/**
 * The <code>Offering</code> class represents a single course offering at Orange Coast College,
 * including its CRN (course registration number), semester code (a number with the year and
 * semester), the <code>Course</code> it is mapped to and the <code>Instructor</code> teaching
 * this offering of the course.
 *
 * @author Michael Paulding
 */
public class Offering {
    private int mCRN;
    private int mSemesterCode;
    private Course mCourse;


    public Offering(int CRN, int semesterCode, Course course) {
        mCRN = CRN;
        mSemesterCode = semesterCode;
        mCourse = course;

    }

    public Offering(int semesterCode, Course course) {
        mSemesterCode = semesterCode;
        mCourse = course;
    }

    public int getCRN() {
        return mCRN;
    }

    public int getSemesterCode() {
        return mSemesterCode;
    }

    public String getSemesterName() {
        switch (mSemesterCode)
        {
            case 201731:
                return "Fall 2017";
            default:
                return "";
        }
    }
    public void setSemesterCode(int semesterCode) {
        mSemesterCode = semesterCode;
    }

    public Course getCourse() {
        return mCourse;
    }

    public void setCourse(Course course) {
        mCourse = course;
    }


    @Override
    public String toString() {
        return "Offering{" +
                "CRN=" + mCRN +
                ", SemesterCode=" + mSemesterCode +
                ", Course=" + mCourse +

                '}';
    }
}
Java
04-11 14:52:59.657 8011-8011/edu.orangecoastcollege.cs273.occcoursefinder E/AndroidRuntime: FATAL EXCEPTION: main
    Process: edu.orangecoastcollege.cs273.occcoursefinder, PID: 8011
    java.lang.IllegalStateException: Could not find method viewOfferingDetails(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.widget.LinearLayout with id 'offeringListLinearLayout'
        at android.view.View$DeclaredOnClickListener.resolveMethod(View.java:4757)
        at android.view.View$DeclaredOnClickListener.onClick(View.java:4716)
        at android.view.View.performClick(View.java:5637)
        at android.view.View$PerformClick.run(View.java:22429)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Posted
Updated 11-Apr-18 21:05pm
v2
Comments
Richard MacCutchan 11-Apr-18 7:56am
   
Please edit your question and remove all the code not related to your problem. Then add proper details of what the problem is and where it occurs.
Maybeok 11-Apr-18 8:27am
   
Hello Richard,All are related each other.Exampl: Main file is CourseSearchActivity , db file is DBHelper . search file is OfferingListAdapter. sub files are course,offering
David Crow 12-Apr-18 8:59am
   
In which file do you have:
android:onClick="viewOfferingDetails"
Maybeok 14-Apr-18 2:50am
   
It is in offering_list_item.xml

<?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:onClick="viewOfferingDetails"
android:clickable="true"
android:id="@+id/offeringListLinearLayout">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/offeringListFullNameTextView" />






1 solution

The exception is clear enough. You have defined onClick in xml layout, but you not adding that method in your activity class. It should have something like this in your activity class.
public void viewOfferingDetails(View view) {
       .....
    });
   
Comments
Maybeok 11-Apr-18 15:52pm
   
Wseng thanks for your information. can you guide me with with spinner inside public void viewOfferingDetails(View view)
wseng 11-Apr-18 21:12pm
   
sure. Can you post your xml layout ?
Maybeok 12-Apr-18 2:43am
   
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_course_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="edu.orangecoastcollege.cs273.occcoursefinder.CourseSearchActivity">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:text="Filter By Instructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
/>

<Spinner
android:id="@+id/instructorSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>



<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<TextView
android:text="Filter By Course Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
/>

<EditText
android:id="@+id/courseTitleEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
/>



<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<button
android:text="@string/reset_button_text"
="" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/resetButton" android:onclick="reset">



<ListView
android:id="@+id/offeringsListView"
android:layout_width="match_parent"
android:layout_height="18dp">



<Spinner
android:id="@+id/ok"
android:layout_width="341dp"
android:layout_height="93dp"
android:layout_weight="1" />
wseng 12-Apr-18 3:04am
   
From the error you post earlier, it looked like you have defined viewOfferingDetails in xml layout, but I didn't see that. Have you changed something in layout ?
Maybeok 12-Apr-18 3:06am
   
no i have not changed anything
wseng 12-Apr-18 3:40am
   
But where the viewOfferingDetails from ?
Maybeok 12-Apr-18 3:50am
   
that is coming from offering
wseng 12-Apr-18 3:53am
   
post offering layout instead.
Maybeok 12-Apr-18 3:59am
   
hi its already pasted in my question.
wseng 12-Apr-18 4:02am
   
you must be defining viewOfferingDetails in somewhere else
Maybeok 14-Apr-18 2:50am
   
wseng finally got it.
<?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:onClick="viewOfferingDetails"
android:clickable="true"
android:id="@+id/offeringListLinearLayout">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/offeringListFullNameTextView" />





wseng 14-Apr-18 5:04am
   
so this layout is refer to which activity ?
Maybeok 14-Apr-18 5:49am
   
refering to CourseSearchActivity
wseng 14-Apr-18 6:04am
   
Once the LinearLayout is clicked, it will call viewOfferingDetails. Is this what you need ?
Maybeok 14-Apr-18 6:10am
   
Actually i am having two requirement here. 1. searching the course with title from edittext which will show in spinner. 2. i should be able to click the spinner to see the inside contents. Please note that requirement 1 is working fine.but looking for requirement 2 solution.
wseng 14-Apr-18 6:19am
   
The viewOfferingDetails will be called after spinner clicked?
Then what is the point you need to have the onClick in linearLayout ?
Maybeok 14-Apr-18 6:22am
   
wseng. onclick can be removable. Suggest me without onclick linearlayout.
wseng 14-Apr-18 6:28am
   
You suppose to have one button . If the button is clicked, it will show the details based on the selected item in spinner.
Maybeok 14-Apr-18 6:29am
   
no without button i need to achieve
wseng 14-Apr-18 6:37am
   
you can refer to this https://stackoverflow.com/questions/12108893/set-onclicklistener-for-spinner-item. You can apply OnItemSelectedListener instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900