|
? ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Have you tried Google? Have you tried the CodeProject articles section?
|
|
|
|
|
|
Good Day All
i have a Navigation Drawer which is defined like this
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:background="#0099ff"
android:layout_height="fill_parent" />
and when one of my drawer item is selected i have this code
FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();
Fragment1 aDifferentDetailsFrag = new Fragment1();
fragmentTx.Add(Resource.Id.content_frame, aDifferentDetailsFrag);
<pre>
fragmentTx.Commit();
Toast.MakeText(this, "Home:", ToastLength.Long).Show();</pre>
and Fragment1 is defined like this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
<pre>
android:paddingLeft="12dp"
android:paddingRight="12dp">
<Button
android:textSize="24dp"
android:textColor="#FFF"
android:id="@+id/btn_details_file_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HOME" />
and the cs is defined like this
public class Fragment1 : Fragment
{
<pre>
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.Inflate(Resource.Layout.Fragment1, null, false);
}
}</pre>
when i run this , i only get a toast message, the Fragment1 does not show which has a button that is having text "home"
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
|
|
|
|
|
Good Day Everyone
I have an activity class defined like this
[Activity(Label = "Activity_Home", MainLauncher = false, Icon = "@drawable/lenderlogo", Theme = "@style/MyTheme")]
public class Activity_Home : ActionBarActivity
{
and the activity is hosting a Tab that display its content from a fragment. A fragment is defined separately and it has a button that is defined like this
<Button
android:textSize="10sp"
android:textColor="#FFF"
android:id="@+id/btn_details_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="btn_details_saveClick"
android:text="Continue" />
as you can see i have a click event that is triggered when the button is clicked. The code to handle the event of the button is defined in the fragment class file like this
Button btn_details_save = FindViewById<Button>(Resource.Id.btn_details_save);
btn_details_save.Click += delegate
{
btn_details_saveClick();
};
and he function itself is defined like this
public void btn_details_saveClick()
{
}
Now when i run the application, the button is click the button the following error occurs
AndroidRuntime(19059): java.lang.IllegalStateException: Could not find method btn_details_saveClick(View) in a parent or ancestor Context for android:onClick attribute defined on view class Button with id 'btn_details_save'
Please note that this is C# code , which means i am using xamarin ,but the error is Android related not Xamarin.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
|
|
|
|
|
My first concern is that you are declaring the click handler twice: once in the layout file, and again in code. Use one or the other, but not both.
Second, you need to change btn_details_saveClick() to accept a View parameter. This is what the error message is actually telling you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thanks for your reply David
"My first concern is that you are declaring the click handler twice: once in the layout file, and again in code. Use one or the other, but not both."
I thought we have to add the click event on the layout file and add hookup the event to the button also in the initialization of the Activity. i learned, thanks. i am coming from asp.net background
i have changed my function in my frament page to be like this
public void btn_details_saveClick(View view)
{
had
and i ran it and i got the Error
java.lang.IllegalStateException: Could not find a method btn_details_saveClick(View) in the activity class android.support.v7.widget.TintContextWrapper for onClick handler on view class android.support.v7.widget.AppCompatButton with id 'btn_details_save'
i have also have a example project( 9mb) on this link Example Project
To Reproduce the Error
1) Open the drawer
2) Click on loan application and click the button "Continue" and you will get an Error
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
modified 30-Aug-17 18:00pm.
|
|
|
|
|
Does the btn_details_saveClick() method belong to the same class that 'owns' the layout?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
If you are defining the click-handler in the .xml file, the click-handler must be implemented in the activity not the fragment. If you are defining the click-handler in the .cs file, the click-handler can be implemented in the fragment.
You'll notice in that example that the btn_details_saveClick() method is contained within the activity PersonalDetailsView rather than the fragment PageFragment .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you David i fixed the issue
after making the PersonalDetailsView inherit from Fragment, all started to work.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vimalsoft.com
vuyiswa[at]vimalsoft.com
|
|
|
|
|
Good evening
I need to insert notifications in my Android application. This is something similar to RSS service.
Therefore I have inserted NotificationCompat.Builder, and Pendig Intent to this purpose. When user selects corresponding item the application is restarted and updated.
But I have a problem, I don't have idea how to fire the notification. I'm thinking to start something like a Timer, every 15-30 minutes connect to server and look for new event released. If there is one, I'll fire Notification through the corresponded object.
Is this a best prtacice? Is there any better way to do?
I would appreciate any sugestions.
Thanks a lot.
|
|
|
|
|
Andy_Bell wrote: I'm thinking to start something like a Timer, every 15-30 minutes connect to server and look for new event released. If there is one, I'll fire Notification through the corresponded object.
Is the goal for the server itself to notify the app, or for the app to notify itself through the server? If the latter, have you looked at Firebase Cloud Messaging[^]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thanks a lot.
No is the first one. Server should notify news incoming to the app when we have uploaded new articles in our database. So user should be advise.
|
|
|
|
|
Would an RSS solution work for you?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Hello ,
My background service is not working .When device is sleep mode.
My background service is running but not update data in webservice..
Any option and any solution my quistion.plz help me any person .
Hi
Regard
Amit
|
|
|
|
|
If you want to send notification you can use --_FIREBASE_--
It is the best and easiest method which i know upto myknowledge
|
|
|
|
|
Hello friends,
i was looking for an idea to implement single android xml and java class file as templet ,to minimise the re-usability of same type of class or xml
Example : I have main.xml which will have 5 buttons on screen ,on first button click i have to load the 2nd screen data from configurator file and based on the configuration the view need to change like hiding 3 buttons or 2 buttons
is it possible to achieve ?
|
|
|
|
|
venky.nani91 wrote: is it possible to achieve ? Probably yes, but it depends on what features are available in the code generator you are using. Visual Studio allows you to create your own project templates; not sure about Android studio.
|
|
|
|
|
THANK YOU FOR REPLAY
|
|
|
|
|
venky.nani91 wrote:
Example : I have main.xml which will have 5 buttons on screen ,on first button click i have to load the 2nd screen data from configurator file and based on the configuration the view need to change like hiding 3 buttons or 2 buttons
is it possible to achieve ? Yes.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi, Thanks for your help in helping me answer all my previous questions, really appreciate that.I have another question related to my android development.I am trying to loop my music player to play the same song infinitely on buttonClick. How Should I do that ?I have already written codes to stop the music player upon playback completion, but can't seem to paste a snap of it on the post.Let me know if I should include the snap.
Thanks
|
|
|
|
|
Member 13341792 wrote: ...play the same song infinitely on buttonClick. Can you put something at the end of the routine (that plays the music file) to check to see if a button has been clicked? If it has, call that routine again.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 12-Aug-17 20:28pm.
|
|
|
|
|
I have tried to move apps to ad card from an android phone. I keep getting a new to format code. Never used to happen. Any thoughts?
|
|
|
|