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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:18:24+00:00 2026-06-10T11:18:24+00:00

I have the following application layout: Activity with a LinearLayout hosting a Fragment, which

  • 0

I have the following application layout:
Activity with a LinearLayout hosting a Fragment, which hosts a ListView in a LinearLayout. I’ve templated (not sure it’s the right term – I’m coming from WPF) how the ListView is displayed. There’s a 3 line part that is shown at all times, plus a ViewStub which is expanded when the item is clicked (and only one item is to be expanded at all times).

Upon the first click on each ListView item, the stub is inflated (works for all items), and then the details and myButton controls are configured. This works for all ListView items – however, for the last of them, details and myButton never show.
On top of that, if another stub is expanded, the last ListView item becomes invisible – instead of it moving down to make space for the item that is currently expanded.

So, if I click on ListView item on position myListView.Items.Count -1, I don’t see anything of the expansion. If I click on any other ListView item, the last ListView item disappears.

Here’s the fragment layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
    android:text="@string/active_calls"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/Calls_Header" />
<ListView
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/ActiveCallsList" />
</LinearLayout>

And the layout for each ListView item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/tableLayout1"
    android:shrinkColumns="*"
    android:stretchColumns="*">
    <TableRow
        android:id="@+id/tableRow1">
        <TextView
            android:text="Caller Name"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/CallerName"
            android:layout_column="0"
            android:layout_span="2" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow2">
        <TextView
            android:text="+41 12 345 6789"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/CallerNumber"
            android:layout_column="0" />
        <TextView
            android:text="00:01:25"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/CallDuration"
            android:layout_column="1" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow3">
        <TextView
            android:text="Ringing"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/CallStatus"
            android:layout_column="0" />
    </TableRow>
</TableLayout>
<ViewStub
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/viewStub1" 
    android:inflatedId="@+id/CallDetails"
    android:layout="@layout/CallDetails" />
</LinearLayout>

and the part to be expanded

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
    android:text="Text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/CallDetailsText" />
<Button
    android:text="@string/endCall"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/EndCallButton" />
</LinearLayout>

And the ItemClick handler associated to my own implementation of an ArrayAdapter deriving from BaseAdapter.

void calls_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
    {
        if (inflatedView != null)
            inflatedView.Visibility = ViewStates.Gone; // make sure only one item is inflated at all times

        var obj = e.Parent.GetItemAtPosition(e.Position);
        var listView = sender as ListView;
        Model.Call t = Model.Calls.MyCalls[e.Position];
        string text = t.CallerName + " " + t.CallState;

        Log.Debug("SmartAppMobile", "Call " + text + " clicked");

        //Toast.MakeText(this.Activity, text, ToastLength.Short).Show();
        ViewStub myStub = e.View.FindViewById<ViewStub>(Resource.Id.viewStub1);

        bool previouslyFound = false;
        if (myStub != null)
        {
            inflatedView = myStub.Inflate();
        }
        else
        {
            Log.Debug("myapp", "View stub not found for " + text);
            inflatedView = e.View.FindViewById<View>(Resource.Id.CallDetails);
            inflatedView.Visibility = ViewStates.Visible;
            previouslyFound = true;
        }

        TextView details = inflatedView.FindViewById<TextView>(Resource.Id.CallDetailsText);
        if (details != null)
            details.Text = "Call details go here... " + t.CallerNumber;
        else
            Log.Debug("myapp", "Call Details Text field not found for " + text);
        Button myButton = inflatedView.FindViewById<Button>(Resource.Id.EndCallButton);
        if (myButton != null)
        {
            if (!previouslyFound)
                myButton.Click += (x, y) =>
                {
                    Model.Calls.MyCalls.Remove(t);
                    //((ArrayAdapter)listView.Adapter).NotifyDataSetChanged();
                    inflatedView.Visibility = ViewStates.Gone;
                };
        }
    }

Also, if I click on myButton, the application reacts as if I had pressed the back button on the phone – and the ListView item is only removed if it is one that I added in code.

So I guess I have to add the way I call the activity hosting the fragment, and how the ListView items are bound as well:

In my fragment hosting the ListView:

    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View fragment = inflater.Inflate(Resource.Layout.CallsFragment, null);
        calls = fragment.FindViewById<ListView>(Resource.Id.ActiveCallsList);
        calls.Adapter = new ActiveCallsAdapter(this.Activity, Model.Calls.MyCalls);
        calls.ItemClick += new EventHandler<AdapterView.ItemClickEventArgs>(calls_ItemClick);

        return fragment;
    }

and my Data model for the calls

public class Calls
{

    private static List<Call> myCalls;

    private static object myLock = new object();

    public static List<Call> MyCalls
    {
        get 
        {
            lock (myLock)
            {
                if (myCalls != null)
                    return myCalls;
                myCalls = new List<Call>();
                myCalls.Add(new Call { CallerName = "some name", CallerNumber = "some phone number", CallState = Model.CallState.Init });
                myCalls.Add(new Call { CallerName = "some other name", CallerNumber = "another number", CallState = CallState.Held });
                return myCalls;
            }
        }
    }

}

And the button I use in my main activity to add a new item to the list and display the list:

Button button = FindViewById<Button> (Resource.Id.myButton);
        button.Click += delegate 
        {
            button.Text = string.Format ("{0} clicks!", count++);
            Model.Calls.MyCalls.Add(new Model.Call { CallerName = "test " + count, CallerNumber = "" + count, CallState = Model.CallState.Active });
            StartActivity(new Intent(this, typeof(CallsActivity)));
        };

And of course, CallsActivity

[Activity(Label = "My Activity")]
public class CallsActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.CallsActivity);
        // Create your application here
    }
}
  • 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-10T11:18:26+00:00Added an answer on June 10, 2026 at 11:18 am

    This is a layout bug. When you inflate the selected call, the call layout gets bigger but its parent doesn’t, so the bottom one falls off the edge. That’s also why it looks like the bottom one is not expanding–the expanded content is falling off the bottom. You can see this in action if you edit CallDetails.axml to set layout_height for the button to 1dp.

    You can fix this layout issue by changing activeCallsList/layout_height (in CallsFragment.axml) to match_parent or fill_parent instead of wrap_content. Instead of reserving just enough space to show the calls when first drawn, activeCallsList will reserve as much space as it can. This makes your call Views behave as expected.

    -Max

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

Sidebar

Related Questions

In my application i have an activity which has the following layout <?xml version=1.0
I have created the following database layout, and started coding the application. The more
In my application, I have a ListView in my main layout. In the corresponding
I have the following code in which I am using the application context to
I have the following activity code for a tabbed application. public class TabbedActivity extends
For my project I have added following line of code in applicaiton.ini resources.layout.layoutPath =
I have the following Application tag code in my widget: <mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns:local=* width=100%
I have the following application: I have 1 window. On that window I add
Lets say that you have a following simple application: <form action=helloServlet method=post> Give name:<input
I have following code in my application: // to set tip - photo in

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.