Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
Xamarin Progress Bar c#
balaji palani
8y
457
1
Reply
I have made a ProgressDialog that should appear immediately before a web service call or some data loading in Button click event
Please see below codes,
addTask = FindViewById<Button>(Resource.Id.myButton);
addTask.Click += (sender, e) => {
progress =
new
Android.App.ProgressDialog(
this
);
progress.Indeterminate =
true
;
progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
progress.SetMessage(
"Loading... Please wait..."
);
progress.Show();
XmlSerializer xm=
new
XmlSerializer(
typeof
(n107_180_68_111.BizInfoFinderSearchResults));
StringWriter writer =
new
StringWriter();
xm.Serialize(writer, result1);
string
xmlContent = writer.ToString();
XmlDocument doc =
new
XmlDocument();
doc.LoadXml(xmlContent);
doc.Save(Console.Out);
try
{
XmlNodeList siteResults = doc.GetElementsByTagName(
"SiteResults"
);
bool
titleRow =
true
;
if
(!
object
.ReferenceEquals(siteResults,
null
))
{
XmlNodeList siteSearchResults = siteResults[0].ChildNodes;
int
count = siteSearchResults.Count;
for
(
int
i = 0; i < count; i++)
{
if
(!
object
.ReferenceEquals(siteSearchResults,
null
))
{
foreach
(XmlNode siteSearchResult
in
siteSearchResults)
{
if
(siteSearchResult.InnerText !=
null
)
{
string
siteID = siteSearchResult.ChildNodes[0].InnerText.Trim();
int
totalhits = Convert.ToInt32(siteSearchResult.ChildNodes[5].InnerText.Trim());
XmlNode results = siteSearchResult.ChildNodes[7];
titleRow =
true
;
finalResults[i] =
new
DataTable();
if
(!
object
.ReferenceEquals(results,
null
))
{
int
rowIndex = 0;
foreach
(XmlNode result
in
results.ChildNodes)
{
if
(titleRow)
{
foreach
(XmlNode col
in
result.ChildNodes)
{
finalResults[i].Columns.Add(col.InnerText.Trim());
}
finalResults[i].Columns.Add(
"SiteID"
);
finalResults[i].Columns.Add(
"TotalHits"
);
titleRow =
false
;
}
else
{
if
(rowIndex > 0)
{
int
colIndex = 0;
DataRow row = finalResults[i].NewRow();
foreach
(XmlNode col
in
result.ChildNodes)
{
row[colIndex] = col.InnerText.Trim();
colIndex++;
}
row[colIndex] = siteID;
row[colIndex + 1] = totalhits;
finalResults[i].Rows.Add(row);
}
}
rowIndex++;
}
}
i++;
}
else
{
count--;
}
}
for
(
int
j = 0; j < count; j++)
{
finalResults[0].Merge(finalResults[j]);
finalResults[0].Columns[
"Name"
].SetOrdinal(0);
}
}
}
}
if
(!finalResults[0].Columns.Contains(
"Status"
))
{
finalResults[0].Columns.Add(
new
DataColumn(
"Status"
,
typeof
(String)));
}
if
(!finalResults[0].Columns.Contains(
"DetailUri"
))
{
finalResults[0].Columns.Add(
new
DataColumn(
"DetailUri"
,
typeof
(String)));
}
if
(!finalResults[0].Columns.Contains(
"Score"
))
{
finalResults[0].Columns.Add(
new
DataColumn(
"Score"
,
typeof
(Double)));
}
if
(finalResults[0].Columns.Contains(
"Type"
))
{
if
(!finalResults[0].Columns.Contains(
"Status"
))
{
finalResults[0].Columns[
"Type"
].ColumnName =
"Status"
;
}
}
if
(finalResults[0].Columns.Contains(
"EntityName"
))
{
if
(!finalResults[0].Columns.Contains(
"Name"
))
{
finalResults[0].Columns[
"EntityName"
].ColumnName =
"Name"
;
}
}
foreach
(DataRow row
in
finalResults[0].Rows)
// Loop over the rows.
{
string
name = row[
"Name"
].ToString().ToLower();
string
keyword = et1.Text.ToString().ToLower();
double
score = System.Math.Round((GOATechnologies.Tools.StringMatch.Match(name, keyword) * 100), 2);
row[
"Score"
] = score;
}
}
catch
(Exception ex) {
string
msg = ex.Message;
}
dt = finalResults [0];
MylistViewAdapter adapter=new MylistViewAdapter(this,businesslist);
lv1.Adapter = adapter;
progress.Hide();
please advice..
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
C# : Start a process in Linux - Issues
Entity Model class changes is it Right?