Page 1 of 1

[Android] ListView

PostPosted: Tue Jun 28, 2016 10:44 pm
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");

Re: [Android] ListView

PostPosted: Sun Jul 03, 2016 12:56 pm
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?

Re: [Android] ListView

PostPosted: Mon Jul 04, 2016 12:04 am
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();

Re: [Android] ListView

PostPosted: Mon Jul 04, 2016 1:39 am
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()

Re: [Android] ListView

PostPosted: Wed Jul 06, 2016 12:21 am
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.