Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:01:51+00:00 2026-06-15T11:01:51+00:00

==================This is my Fragment: public class ChooseAssigmentFragment extends Fragment { private ListArrayAdapter listArrayAdapter; private

  • 0

==================This is my Fragment:

public class ChooseAssigmentFragment extends Fragment {
private ListArrayAdapter listArrayAdapter;

private Assigment assigment;

private Assigments assigments;

private ListView assigList;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.assigments, null);
    init(v);
    assigments = new Assigments();
    assigment = new Assigment("Nikon D700", "aisle 5, range 1m");
    assigments.add(assigment); // daca comentez linia, atuncia functioneaza assigment.name si assigment.details nu is nule
    loadAssigments(assigments);

    return v;
}

private void init(View v) {
    // TODO Auto-generated method stub
    EditText assigSearchET = (EditText) v.findViewById(R.id.assigSearchET);
    ImageButton assigSearcthIB = (ImageButton) v.findViewById(R.id.assigSearchIB);
    assigList = (ListView) v.findViewById(R.id.assigListView);

    assigList.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> assigList, View v, int position, long id) {
            Assigment assigment = ((ListArrayAdapter) assigList.getAdapter()).getItem(position);
            LogService.log(getTag(), "position: " + assigList.getAdapter().getItem(position));

        }
    });

}

private void loadAssigments(Assigments assigments) {

    listArrayAdapter = new ListArrayAdapter(ChooseAssigmentFragment.this, assigments);

    listArrayAdapter.notifyDataSetChanged();
    assigList.setAdapter(listArrayAdapter);
}

}

========================This is my ListView adapter:

public class ListArrayAdapter  extends BaseAdapter implements Filterable {
private final LayoutInflater mInflater;
private ChooseAssigmentFragment chooseAssigmentFragment;
private Assigments assigments;
private Object mFilter;

public ListArrayAdapter(ChooseAssigmentFragment chooseAssigmentFragment, Assigments assigments) {
    this.chooseAssigmentFragment = chooseAssigmentFragment;
    this.assigments = assigments;
    mInflater = LayoutInflater.from(chooseAssigmentFragment.getActivity());
}


public int getCount() {
    return assigments.size();
}

public Assigment getItem(int position) {
    return assigments.get(position);
}

public long getItemId(int position) {
    return position;
}

public Assigment getAssigments(int i) {
    return assigments.get(i);
}

public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ItemFilter();
    }
    return (Filter) mFilter;
}


public View getView(int position, View convertView, ViewGroup parent) {

    ListContent holder = null;

    Assigment assigment = getAssigments(position);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.row_layout_main_fragment, null);

        holder = new ListContent();
        holder.assigName = (TextView) convertView.findViewById(R.id.listItemName);
        holder.assigDetails = (TextView) convertView.findViewById(R.id.listItemDetails);

        convertView.setTag(holder);
    } else {
        holder = (ListContent) convertView.getTag();

    }
    holder.assigName.setText(assigment.name);
    holder.assigDetails.setText(assigment.details);

    return null;
}
private class ItemFilter extends Filter {
    @Override
    protected FilterResults performFiltering(CharSequence prefix) {
        return null;

    }

    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) {

    }
}

class ListContent {
    TextView assigName;
    TextView assigDetails;

}
}

=================My Inflater xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout02"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFFFFF"
    android:orientation="vertical"
    android:paddingLeft="5dp" >

<TextView android:id="@+id/listItemName" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_weight="1"
    android:text="@+id/listItemName" android:textSize="18dp"
    android:lineSpacingExtra="15dp" android:textStyle="bold"
    android:textColor="@color/Black">
</TextView>

<TextView android:id="@+id/TextView02" android:layout_width="wrap_content"
    android:layout_height="1dp">
</TextView>

<TextView android:id="@+id/listItemDetails" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_weight="1"
    android:text="@+id/listItemDetails" android:textSize="14dp"
    android:lineSpacingExtra="15dp"
    android:textColor="@color/DarkGray">
</TextView>

</LinearLayout>

====================My xml Fragment file:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/RelativeLayout2"
    android:layout_width="match_parent"
    android:layout_height="20dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="@color/SlateGray"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
        android:text="@string/sensor_conf" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="45dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/RelativeLayout2"
    android:weightSum="8" >

    <EditText
        android:id="@+id/assigSearchET"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="7" >

        <requestFocus />
    </EditText>

    <ImageButton
        android:id="@+id/assigSearchIB"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.99"
        android:background="@color/white"
        android:src="@drawable/ic_action_search" />
</LinearLayout>

<ListView
    android:id="@+id/assigListView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout1"
    android:layout_centerHorizontal="true" >
</ListView>

</RelativeLayout>

=================And this is what my Logcat gives me:

12-06 11:35:54.156: E/AndroidRuntime(26171): FATAL EXCEPTION: main
12-06 11:35:54.156: E/AndroidRuntime(26171): java.lang.NullPointerException
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.AbsListView.obtainView(AbsListView.java:2048)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.ListView.onMeasure(ListView.java:1127)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.measureChild(RelativeLayout.java:566)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:381)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.View.measure(View.java:8459)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewRoot.performTraversals(ViewRoot.java:864)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1902)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.os.Looper.loop(Looper.java:130)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at android.app.ActivityThread.main(ActivityThread.java:3744)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at java.lang.reflect.Method.invokeNative(Native Method)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at java.lang.reflect.Method.invoke(Method.java:507)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-06 11:35:54.156: E/AndroidRuntime(26171):    at dalvik.system.NativeStart.main(Native Method)

I tried changing the fragment xml, to contain only the list, tried to change the inflated xml, but still no luck. I have no ideeas left

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:01:52+00:00Added an answer on June 15, 2026 at 11:01 am

    Your getView() of the adapter is returning null. You should return convertView:

    public View getView(int position, View convertView, ViewGroup parent) {
    
        ListContent holder = null;
    
        Assigment assigment = getAssigments(position);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.row_layout_main_fragment, null);
    
            holder = new ListContent();
            holder.assigName = (TextView) convertView.findViewById(R.id.listItemName);
            holder.assigDetails = (TextView) convertView.findViewById(R.id.listItemDetails);
    
            convertView.setTag(holder);
        } else {
            holder = (ListContent) convertView.getTag();
    
        }
        holder.assigName.setText(assigment.name);
        holder.assigDetails.setText(assigment.details);
    
        return convertView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this fragment: public class Fragment_PV extends Fragment { @Override public View onCreateView(LayoutInflater
I have this code fragment: public static class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {
I'm trying to create a list fragment activity like this : public class FluxListeFragment
This is a code fragment from my controller [HttpPost] public ActionResult Cancel(string id,FormCollection collection)
When I run this code fragment, neither side is taken. if (Boolean.class.isAssignableFrom(boolean.class)) { uLog.error(Boolean
This is fragment of class in my program (I deleted some not important code).
I'm trying to create a fragment class following from this: And they give you
I have a Pager adapter that will call a ListFragment like this: public Fragment
I'm trying to make this fragment work: Version History --------------- These are the versions
I have a Fragment with ImageView . How I can show this Fragment on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.