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 7853791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:48:14+00:00 2026-06-02T19:48:14+00:00

I tried to combine those two source codes (http://stackoverflow.com/questions/9697716/listview-displays-each-item-twice-after-filtering and http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/ ) in order

  • 0

I tried to combine those two source codes (http://stackoverflow.com/questions/9697716/listview-displays-each-item-twice-after-filtering and http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/) in order to make two tabs in which one of them has a listview with a searchbox.

public class TabsFragment extends Fragment implements OnTabChangeListener {

private static final String TAG = "FragmentTabs";
public static final String TAB_ALLSERVICES = "allservices";
public static final String TAB_MOSTUSEDSERVICES = "mostusedservices";

private View mRoot;
private TabHost mTabHost;
private int mCurrentTab;

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.tabs_fragment, null);
    mTabHost = (TabHost) mRoot.findViewById(android.R.id.tabhost);
    setupTabs();
    return mRoot;
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);

    mTabHost.setOnTabChangedListener(this);
    mTabHost.setCurrentTab(mCurrentTab);
    // manually start loading stuff in the first tab
    updateTab(TAB_ALLSERVICES, R.id.tab_1);
}

private void setupTabs() {
    mTabHost.setup(); // important!
    mTabHost.addTab(newTab(TAB_ALLSERVICES, R.string.tab_allservices,
            R.id.tab_1));
    mTabHost.addTab(newTab(TAB_MOSTUSEDSERVICES,
            R.string.tab_mostusedservices, R.id.tab_2));
}

private TabSpec newTab(String tag, int labelId, int tabContentId) {
    Log.d(TAG, "buildTab(): tag=" + tag);

    View indicator = LayoutInflater.from(getActivity()).inflate(
            R.layout.tab,
            (ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
    ((TextView) indicator.findViewById(R.id.text)).setText(labelId);

    TabSpec tabSpec = mTabHost.newTabSpec(tag);
    tabSpec.setIndicator(indicator);
    tabSpec.setContent(tabContentId);
    return tabSpec;
}

@Override
public void onTabChanged(String tabId) {
    Log.d(TAG, "onTabChanged(): tabId=" + tabId);
    if (TAB_ALLSERVICES.equals(tabId)) {
        updateTab(tabId, R.id.tab_1);
        mCurrentTab = 0;
        return;
    }
    if (TAB_MOSTUSEDSERVICES.equals(tabId)) {
        updateTab(tabId, R.id.tab_2);
        mCurrentTab = 1;
        return;
    }

}

private void updateTab(String tabId, int placeholder) {
    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(tabId) == null) {
        if (tabId.equals(TAB_MOSTUSEDSERVICES)) {
            fm.beginTransaction()
                    .replace(placeholder, new MostUsedServicesFragment(), tabId)
                    .commit();
        } else if (tabId.equals(TAB_ALLSERVICES)) {
            fm.beginTransaction()
            .replace(placeholder, new Fragmenttest(), tabId)
            .commit();
        }
    }
}
}

tabs_fragment.xml looks like following:
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#EFEFEF">

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

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <FrameLayout
                android:id="@+id/tab_1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

            <FrameLayout
                android:id="@+id/tab_2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

        </FrameLayout>
</LinearLayout>
</TabHost>

public class Fragmenttest extends ListFragment {
ListView newReqList;
LayoutInflater inflater;
String[] from = new String[] { "mainrow", "subrow" };
EditText searchBar = null;
ArrayAdapter<String> sAdapter = null;
private static final String[] NUMBERS = { "1", "2", "3", "4", "5", "VI",
        "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV" };

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    newReqList = this.getListView();

    searchBar = (EditText) this.getActivity().findViewById(R.id.search_box);
    List<String> l = new ArrayList<String>();

    for (String s : NUMBERS) {
        l.add(s);
    }
    sAdapter = new ArrayAdapter<String>(this.getActivity(),
            R.layout.list_item, l);
    newReqList.setAdapter(sAdapter);
    searchBar.addTextChangedListener(filterTextWatcher);
}

private TextWatcher filterTextWatcher = new TextWatcher() {

    public void afterTextChanged(Editable s) {
    }

    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
    }

    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
        sAdapter.getFilter().filter(s);
        sAdapter.notifyDataSetChanged();
    }

};

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.allservices, container, false);
    return v;
}
}

The allservices.xml looks like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<!-- Pretty hint text, and maxLines -->

<EditText
    android:id="@+id/search_box"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/allserviceshint"
    android:inputType="text"
    android:maxLines="1" />

<!-- Set height to 0, and let the weight param expand it -->
<!--
     Note the use of the default ID! This lets us use a 
     ListActivity still!
-->

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1" />
</LinearLayout>

As soon as I run the application, I get following LogCat:

04-19 04:59:04.276: E/AndroidRuntime(4106): FATAL EXCEPTION: main
04-19 04:59:04.276: E/AndroidRuntime(4106): java.lang.RuntimeException: U_MISSING_RESOURCE_ERROR

Does anyone know what that means and how I can fix it?

Best Regards, Roman.

  • 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-02T19:48:15+00:00Added an answer on June 2, 2026 at 7:48 pm

    I solved the Problem by changing the allservices.xml to following:

    <?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:background="@android:drawable/gallery_thumb"
    android:orientation="vertical" >
    
    <EditText
        android:id="@+id/search"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Hallo"
        android:inputType="text"
        android:maxLines="1" />
    
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >
    
        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:drawSelectorOnTop="false" />
    
        <TextView
            android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="No items."
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </FrameLayout>
    </LinearLayout>
    

    Adding a Framelayout did the trick. I think without the FrameLayout the Listview made the Edittext disappear and so the U_MISSING_RESOURCE_ERROR was thrown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
So I have been trying to combine the answers of these two questions: C#
I recently tried to combine SEAM and GWT in a project - but failed
Is it possible to combine ARC and non-ARC projects? I haven't really tried it
I have two arrays I want to combine. I need to take the values
Is it at all possible to combine two different query results into one feed
If we know that we can use var link = $('a[href=http://google.com]'); when we want
I have two XML docs that I've created and I want to combine these
I need to compare two tables and then filter out only those records that
I need to combine two mod_rewrite rules into one. 1) In CMS, there is

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.