[Android] ListView

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Post Reply
Lena
BCBJ Master
BCBJ Master
Posts: 668
Joined: Sun Feb 06, 2011 1:28 pm

[Android] ListView

Post by Lena »

In C++ Builder XE7 no problem with this code:

Code: Select all

void __fastcall TMainForm::ListView1UpdatingObjects(const TObject *Sender, const TListViewItem *AItem,
          bool &AHandled)
{
 TListItemText * LCaption = reinterpret_cast<TListItemText*>((const_cast<TListViewItem*>(AItem))->Objects->FindObject(sText));
 if (LCaption == NULL)
   {
      LCaption = new TListItemText((TListItem*)AItem);
      LCaption->Name = sText;
      LCaption->Align = TListItemAlign::Trailing;
      LCaption->VertAlign = TListItemAlign::Trailing;
      LCaption->PlaceOffset->X = 15;
      LCaption->PlaceOffset->Y = 12;
      LCaption->TextAlign = TTextAlign::Center;
      LCaption->Trimming = TTextTrimming::Character;
      LCaption->IsDetailText = True;
      LCaption->Width = 90;
      LCaption->Height = 45;
   }
}

//***
const System::UnicodeString sText = L"CA"; //<- in h file


TListViewItem * item = ListView1->Items->Add();
item->Text = L"Main text";
item->Detail = L"Detail text"
item->BitmapRef = Image1->Bitmap;
item->Data[sText] = TValue::From<UnicodeString>(L"The text on the right"); //<- I do not see this text in ListView

//***

Why it does not work in Berlin?
item->Data[sText] = TValue::From<UnicodeString>(L"The text on the right");
rlebeau
BCBJ Author
BCBJ Author
Posts: 1699
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: [Android] ListView

Post by rlebeau »

Lena wrote:Why it does not work in Berlin?


You tell us. What is the actual problem you are having with it? Does the code compile? Or just not behave correctly at runtime? Are you taking into account that TListView was refactored in Seattle?
Remy Lebeau (TeamB)
Lebeau Software
Lena
BCBJ Master
BCBJ Master
Posts: 668
Joined: Sun Feb 06, 2011 1:28 pm

Re: [Android] ListView

Post by Lena »

I open my old project and successfully compile in Berlin. No error.
But item->Data[sText] emty
item->Data[sText] = TValue::From<UnicodeString>(L”Test");//I do not see the word "Test" in ListView1
I try change FindObject to FindDrawable but it did not help

Code: Select all

//filling code
std::map<String, std::vector<String> >::iterator It = IniContent.begin();
         int i = 1;
         ListView1->BeginUpdate();
          while (It != IniContent.end())
           {
            TListViewItem * item = ListView1->Items->Add();
            item->Text = L"№" + IntToStr(i) + " " + IniContent[(*It).first][1];//OK
            item->Detail = MainForm->IniContent[(*It).first][2];//OK
            item->BitmapRef = Image1->Bitmap;//OK
            item->Data[sText] = TValue::From<UnicodeString>((*It).first);//time
            //item->Data[sText] emty in ListView1 :(
            ShowMessage((*It).first);//<-here I see string "13:00"
            It++;
            i++;
           }
         ListView1->EndUpdate();
rlebeau
BCBJ Author
BCBJ Author
Posts: 1699
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: [Android] ListView

Post by rlebeau »

Lena wrote:I open my old project and successfully compile in Berlin. No error.
But item->Data[sText] emty


Did you check to make sure that TValue::From() itself is returning a non-blank value to begin with?

Code: Select all

TValue v = TValue::From<UnicodeString>(L"The text on the right");
UnicodeString s = v.AsString(); // or v.ToString()
Remy Lebeau (TeamB)
Lebeau Software
Lena
BCBJ Master
BCBJ Master
Posts: 668
Joined: Sun Feb 06, 2011 1:28 pm

Re: [Android] ListView

Post by Lena »

I see the text "The text on the right". But in ListView1 empty.
I stopped trying to compile my old android application in Berlin. A lot of problems.
For example turn the device 90 degrees and get segmentation fault and app crashes.
There are no such problems in C++ Builder XE7.
Post Reply