Hi Tofu !
You are right , Kuix.getFrameHandler() contains a unique and static instance for all the application, I am not cretaing any nonStaic instance of the second Frame, but again the static one ..
I am posting here the code snippet..
I hope the problem will be visible now ..
SearchFrame.java
public class SearchFrame implements
Frame {
public static final SearchFrame instance = new
SearchFrame();
DataList
myList = new
DataList();
ResultDataProvider
resultDetail = new
ResultDataProvider();
Screen
screen
;
String [][]
str= {{"Hi", "Welcome To the World of Kuix !"},{"Hello !","How greatly U R enjoying It ? "
}};
public void
onAdded() {
screen = Kuix.loadScreen("/xml/mySearch.xml", myList
);
screen
.setCurrent();
}
public boolean
onMessage(Object arguments, Object[] arg1)
{
if("show"
.equals(arguments))
{
Widget focusedWidget =
screen
.getFocusManager().getFocusedWidget();
if (focusedWidget instanceof
ListItem) {
DataProvider dataprovider = ((ListItem) focusedWidget).getDataProvider();
if(dataprovider !=null
)
{
ResultDataProvider result = (ResultDataProvider) dataprovider;
SearchItem.
instance
.setResult(result);
System.
out
.println(result);
//searchDetail();
Kuix.getFrameHandler().pushFrame(SearchItem.
instance
);
}
}
return false
;
}
if("search"
.equals(arguments))
{
for (int i=0; i<str.length
; i++)
{
myList.addItem(DataList.LIST_PROPERTRY, new ResultDataProvider(str[i][0],str
[i][1]));
}
}
return false
;
}
public void
onRemoved() {
myList= null
;
resultDetail = null
;
screen = null
;
}
}
searchItem.java
public
class SearchItem implements
Frame {
public static final SearchItem instance= new
SearchItem();
Screen
screen
;
public ResultDataProvider result
;
public
SearchItem()
{}
public void
setResult(ResultDataProvider result) {
this.result
= result;
System.
out.println("<-----In Frame Search Item--------->"
);
System.
out.println(result.getStringValue("resultLabel"
));
);
}
public void
onAdded()
{ System.
out.println("In On Added Method"
);
System.
out.println(result.getStringValue("resultDetail"
));
screen= Kuix.loadScreen("/xml/searchDetail.xml", result
);
screen
.setCurrent();
}
public boolean
onMessage(Object identifier, Object[] arg1) {
if("backPage"
.equals(identifier))
{
Kuix.getFrameHandler().removeFrame(
instance
);
return false
;
}
return false
;
}
public void
onRemoved() {
result = null
;
screen = null
;}
ResultDataProvider.java
public
class ResultDataProvider extends DataProvider
{
public String resultLabel;
public String resultDetail;
public ResultDataProvider(String resultLabel, String resultDetail)
{
this.resultLabel=resultLabel;
this.resultDetail=resultDetail;
}
public ResultDataProvider ()
{
}
public String getStringValue(String property) {
if("resultLabel".equals(property))
{
return resultLabel;
}
if("resultDetail".equals(property))
{
return resultDetail;
}
return super.getStringValue(property);
}
void setResultLabel(String resultLabel) {
this.resultLabel = resultLabel;
}
public void setResultDetail(String resultDetail) {
this.resultDetail = resultDetail;
}
}
DataList.java
public
public static final String LIST_PROPERTRY ="results"
;}
mySearch.xml
class DataList extends DataProvider
{
<
screen style="layout:borderlayout">
<container style="layout-data:bld(north);layout:borderlayout">
<textfield id="myTextfield" style="layout-data:bld(center)"/>
<button style="layout-data:bld(east)" onAction="search(myTextfield.text)">GO</button>
</container>
<container style="layout-data:bld(center)">
<list>
<_renderer><![CDATA[
<listItem style="layout:borderlayout;gap:5 0" onAction="show">
<listItem><text>@{resultLabel}</text></listItem>
</listItem>
]]></_renderer>
<_items>@{results}</_items>
</list>
</container>
</
screen>
serchDetail.xml
<
screen>
<_title>@{resultLabel}</_title>
<scrollPane usemarkers="false" style="align:fill-center;layout:inlinelayout(false,fill);gap:1 5">
<textarea style="padding: 2 0 1 1">@{resultLabel}</textarea>
<textarea style="padding: 10 10 15 10">@{resultDetail}</textarea>
</scrollPane>
<screenfirstmenu onAction="backPage">%BACK%</screenfirstmenu>
<screenSecondMenu>
%MENU%
<menupopup>
<menuitem onAction="goHome">%HOME%</menuitem>
<menuitem onAction="exit">%EXIT%</menuitem>
</menupopup>
</screenSecondMenu>
</
screen>
Above Given Code snippet work fine .. it gives me list on search though String str[i][0], onAction of this selected ListItem again It gives me the value of str[i][1] in sublist,
The Problem comes in picture when, I am trying to return back to the list of str[i][0] from sublist str[i][1]; The Application slightly behaves idle when , I am pressing back to return the mainList.
How do I can return to the mainList, from the sublist ? I Hope , My problem Will be clear to You now .