GraphView within a dialog not working

GraphView within a dialog not working



When I place the below codes (while removing GraphDialog in front of the findViewById) in my MainActivity.java, it works perfectly.



But when I place it inside my dialog "GraphDialog", logcat error pointed to this line (see comment lines)
Appreciate so much if anyone can help me out! Thanks!


//Graph View function
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void ShowGraphview(View v)
GraphView graphResult = GraphDialog.findViewById(R.id.graph);
GraphDialog.setContentView(R.layout.ivb_popup_graphview);
btn_close = GraphDialog.findViewById(R.id.dia_btn_close);
GraphDialog.setCanceledOnTouchOutside(true);

//Apply Graph view
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint
new DataPoint(0, 6),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
);

//------------This line is where the logcat error pointed to-------
graphResult.addSeries(series);
//------------logcat error pointed to------------------------------

/*Close Button */
btn_close.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
GraphDialog.dismiss();

);
GraphDialog.show();




1 Answer
1



Works when I swap these 2 lines....


GraphView graphResult = GraphDialog.findViewById(R.id.graph);

GraphDialog.setContentView(R.layout.ivb_popup_graphview);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế