Question A newbie Android Application - Samsung Galaxy Z Flip 3

I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

pax0 said:
I'm a newbie to Android Application.
I would like to add a functionality to my button. What should I touch ?
View attachment 5523271
Click to expand...
Click to collapse
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {n
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.

wpscully said:
You appear to have successfully created the graphical portion of your application. For it to do something truly useful requires code: Java or Kotlin. I think this app you're working on is setup for Java. So the short answer is "Write some Java code and put it into MainActivity.java."
Since you mention you're a beginner here's a longer answer. You might was to skim through this tutorial until they get to the parts about writing Java code.
Build Your First Android App in Java | Android Developers
In this codelab, you’ll build your first Android app. You’ll learn how to use Android Studio to create an app, add UI elements, known as views, to your app, and add click handlers for the views. You’ll finish by adding a second screen to your app.
developer.android.com
Here's a couple of lines code of which might make sense to you. I've added the attribute "onClick" onto the button in the XML file. And I've added a few lines of Java code which will run when the button is clicked. The end result is a brief message (this message is called "a toast") on the phone's screen saying "Click!" Obviously you'll want to do more than this trivial example.
So, consider adding these attributes to your activity_main.xml file's "button"
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidnClick="button1"
android:text="First Button" />
And you MainActivity.java might look like:
package com.example.my;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void button1(View view) {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
}
}
Hope this is helpful to you.
Click to expand...
Click to collapse
That's a good start, but I think you did some iOS button handling
For a button, you need to get a reference to it in your Java and assign a click listener. It won't automatically find it like Xcode by using the same name.
Code:
...
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button1);
button.setOnClickListener(view -> {
Toast.makeText(getApplicationContext(), "Click!", Toast.LENGTH_LONG).show();
});
...
In older Android Studio, you had to do
Code:
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
but now you can use a lambda (->) to replace the "common" stuff

the suggested solutions gives plenty of errors see below.

Hi. Speaking of Android development anybody know where can I find the C++ and Java Android development section of this forum? Thanks!

It gives plenty of errors

The sample Java program I posted in post #2 was meant to "largely replace" all the lines in MainActivity.java. It looks like you cut/pasted some of the suggested code into the middle of the existing skeleton Java code which Android Studio creates on your behalf. That approach won't work... a bit more effort is involved.
For example, there should be one and only one record in the Java file starting with the work "package". In your screen shot I see two. The second occurrence is incorrect and probably causing most of the errors. I would keep the first occurrence of package, because that's the naming that your Android Studio gave to the program. Delete the second "package com.example.my" which I think you pasted from me into the original file.
Also, there are several "import" records needed. In my post I included the only four I thought would be needed. However in your screen shot, on the second line, I see an import record with "three dots" (an ellipsis). This is Android Studio's way of hiding code from your view, which can be confusing to new users. You should mouse-click on those three dots to expose the hidden code. Then make sure there are no duplicate import records, when comparing what was originally in the file with what you cut/pasted.
I sent a private message to you with a link to my example code. It might work for you if you copied the folder into the same location you save your Android Studio projects. Of course, I can't be sure it will work. That's why I thought it best to include just a few lines of code in my original post.
Naming of things in Android Studio matters. I called my button "button" and my onClick "button1" and it must match eXaCtLy in the XML file and the Java code. (Case matters.) I can't see all your code so you'll need to ensure the naming matches exactly. (It's intuitively better if you name your button more appropriately... like "submit" if that's what the button is supposed to do.) Also, the number of braces { } will matter, as they indicate the structure of the program in Java.
In closing, it's very hard to explain all the nuances of this development environment through posting on XDA. Which is why it may be worth your time to run through the tutorial from Google. The tutorial creates a very simple application, but it also shows a lot of what I think you want to do, which is layout an end-user interface and have a button which when pressed will go off and do some additional work.
PS: I saw some errors in post 2, which I've cleaned up. A colon and the oh was interpreted as an emoticon. Ugh.
There's a learning curve involved here... learning Android Studios. If you can figure it out you might be able to earn a good living! I confess it's too hard for me. ;-)

pax0 said:
the suggested solutions gives plenty of errors see below.
View attachment 5523855
Click to expand...
Click to collapse
Your best bet is to start small. Download an example project from an online tutorial. The ones from Google are typically garbage. Plenty of sites include a sample with their getting started.
Make a small change and see what happens when you run it. Try a bigger change next. Try adding something. Try starting a new project. Try adding your stuff to that. Next thing you know, you're explaining it to the next person.
Admittedly, this isn't a section really made for learning the basics of app development. It's more focused on one device. General will be more help.

Related

[Q] First WM 6.1 app (NEED HELP)

Hello everyone,
I am new at this forum and I am just starting to learn programming for pocket PCs, especialy for Xperia. I have a few questions, hope you can give me an answer for them. There they are:
1. What librararies are essential for "hello world" app?
2. I managed to create "hello world" with C# but it only works as an alert box, how to make a normal window with left and right buttons.
3. I have SDK 6.0, do I need to get 6.1?
4. What library has a command for normal text output (I.e. cout, print, wrinteln...) and how does it look like?
5. How do I know if my app I am developing needs .NET framework 3.5?
6. I don't have much time to read all topics, but if there are answers to any of my questions in them, please tell me where I can find them.
I am not sure if I am posting in the right place, so if I am wrong, please tell me.
http://wiki.xda-developers.com/index.php?pagename=Development Tools
it has alot of info
I can only find what software I need to develop, but I already have 2008 visual studio. Maybe you know another page where I could find simple code examples of using windows, messages, links and other codes.
try MSDN Libraries, they are VERY Helpful
I know but they are still very difficult for someone like me. Maybe someone can just answer my questions in the first post? I just need to have a basic window script for C#, instead of alert message box script that I have managed to write myself.
No, you do not need SDK 6.1 for that! I am still running on the SDK6 and I am using the WM5 Emulator - it works just fine.
There are no essential libraries for a HELLO WORLD application. All you have to do, is, to create a new PROJECT for smart devices in your prefered programming language. Select as type Windows Application (or however it is called in English - I am using the German VS2008, so, I am a bit unsure).
Below you will find a sample in VB2008 - sorry, I just prefer VB but you can easily convert the code to C#.
If you hit the left button, it will fill the text "HELLO WORLD" into a textbox control, if you hit the center button, the textbox control will be empty, if you hit the right button, you will get a messagebox with "HELLO WORLD!".
I hope that helps getting you started? For advanced questions I would suggest that you check out the MSDN Forums. Mostly, what works for desktop application works for smart devices too.
You will know if the app you're creating needs .NET3.5 if you select .NET3.5 while starting your project!
Pay attention when starting a new project, you will see a combobox at the top right where you can target a specific .NET FRAMEWORK. Simply select the .NET Version you want to use. I always select 2.0 - this is the most commonly used framework.
Thanks for your answers. Unfortunatly I get an error opening the file:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Maybe you can post code here? And how should I convert it? Using VS2008?
I guess you check your installation of VISUAL STUDIO 2008! It does not appear to me that you have the full VS2008 intsalled but the EXPRESS EDITION of C#.
The error you pictured above tells you already that you do not have VB2008 installed, therefore it can't open the project.
Visual Studio 2008 (commercial version - not EXPRESS EDITIONS) has build-in Development environment for smart devices, including PDA's. There are no additional libraries needed. Posting thye code here wouldn't make much sense since you only would see something like:
Code:
MessageBox.Show("Hello World", "Hello Sample")
You can open the Form1.vb and also the Form1.Designer.vb with any text editor, so, there is no need to repost the entire code here.
I prefer eVC£«£«.It's free.
Hello,
it has been quite a while, since I last wrote. I had abandoned developing for all that time. Recently I started to develope again, this time for real, I hope, and made a little progress. Now I have a very annoying problem. I want to add background image to my app, but I get error, that it can't be found.
Location of image:
C:\Documents and Settings\Martin\Desktop\Xperia\MMCalc\Properties\image.jpg
Reference to image:
Code:
backgroundImage = new Bitmap(@"\Program Files Folder\MMCalc\Properties\image.jpg");
Image is added to properties in visual studio and output file folder is:
Program Files Folder\MMCalc
Error:
{"Could not find a part of the path '\\Program Files Folder\\MMCalc\\Properties\\image.jpg'."}
I tried different paths many times, but all i got is that error, hope you can help me, since I couldn't find anything on google...

Fullsize Home Screen Icon for Websites or Web Applications

Hi y'all.
Full Icons for the desktop are much better and should be used when available as opposed to the "lapel" style that android does natively.
Problem:
Today I got a google wave invite and brought up the mobile version. Then I added an icon to my desktop for easy access. Here is what it looked like (the bookmark text was edited)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As you can tell, it looks like a regular bookmark link but has the little google wave lapel. A bunch of sites do this.
However, when the same bookmark is make on the iphone it looks like this (bottom row, next to the poop icon) (not my phone had buddy ss it for me)
Here is the apple documentation for retrieving this icon:
How do I create a Home screen icon for my website or web application?
Safari on iPhone OS allows users to save a bookmark to your website or web application on the Home screen, alongside icons for native applications. For this bookmark, you can specify a single icon for your entire site or application by placing a 57 x 57 pixel .png image named apple-touch-icon.png in the root directory of your website. Or, to provide a specific icon for a section or page, use a link tag that defines the relationship as apple-touch-icon and includes a link to the icon image, as shown in Listing 3.
Listing 3: Specifying a per-page Home screen icon
<link rel="apple-touch-icon" href="/my_custom_icon.png"/>
Guidelines for creating Home screen icons are available in the "Create an Icon for Your Web Application or Webpage" section of the iPhone Human Interface Guidelines for Web Applications], and detailed information about linking your icon to your web content can be found in the "Specifying a Webpage Icon for Web Clip" section of the Safari Web Content Guide for iPhone OS.
Click to expand...
Click to collapse
http://www.devworld.apple.com/safari/library/codinghowtos/Mobile/UserExperience/index.html#GENERAL-CREATE_A_HOME_SCREEN_ICON_FOR_MY_WEBSITE_OR_WEB_APPLICATION
some more implementation details on the sites side
An article about today about the mobile google wave site and this logo
I am not a coder but am a product manager for software dev, so i can't code this up myself effectively.
Initial Proposal / Method
My guess would be that we need to edit the way a bookmark is stored and create an additional parameter which would be pulled from here
<link rel="apple-touch-icon" href="/my_custom_icon.png"/>
Click to expand...
Click to collapse
and then the core would need to be editing to display that additional parameter if not null when the bookmark shortcut is made.
Anyone interested?
I agree about the icons: it makes a lot of sense to give web shortcuts "full citizenship".
Where did you get that cool wood wallpaper?
Thanks
The background (the document with the earth on) is determined by the the image ic_launcher_shortcut_browser_bookmark.png in the drawables folder of Browser.apk and is easily changed if you know how (any themer does). The additional icon (the Wave logo) is added (by Launcher(?)) to the general bookmark icon if the site has a favicon.
/Mats
I know this isn't a resolve, but I just use Better Cut to change the icon to a custom icon I made or found. That's why my browser looks like Chrome, etc..
i love sweet icons like that
(big and cool)
ZilverZurfarn said:
The background (the document with the earth on) is determined by the the image ic_launcher_shortcut_browser_bookmark.png in the drawables folder of Browser.apk and is easily changed if you know how (any themer does). The additional icon (the Wave logo) is added (by Launcher(?)) to the general bookmark icon if the site has a favicon.
/Mats
Click to expand...
Click to collapse
Great!
However a themer is just swapping out png's correct? Not actually writing code to pull the png from different places depending on certain properties of the target?
Is it possible to not only save the favicon but also to store the custom_icon if available and then have the launcher display that instead?
PCTechNerd said:
I know this isn't a resolve, but I just use Better Cut to change the icon to a custom icon I made or found. That's why my browser looks like Chrome, etc..
Click to expand...
Click to collapse
Yea I did this little trick for a facebook shortcut. Its okay, but would work better/faster if it did it on its own.
Maybe initially, we could have the launcher display just the favicon and not the overlaid deal?
DownloaderZ said:
Great!
However a themer is just swapping out png's correct? Not actually writing code to pull the png from different places depending on certain properties of the target?
Click to expand...
Click to collapse
Correct.
DownloaderZ said:
Is it possible to not only save the favicon but also to store the custom_icon if available and then have the launcher display that instead?
Click to expand...
Click to collapse
I guess the Launcher could be persuaded to behave like that. But that's an issue for Launcher hackers, like irrenhaus: http://forum.xda-developers.com/showthread.php?t=540880
I'm afraid the favicon only would look terrible, as it's just a 16x16 image that would be resized to 48x48:
However, by changing the std shortcut png in Browser, things can be improved:
/Mats
Are there any devs interested in helping out? (man, this sounds like a desperate plea)
Wow this is a really good idea. So basically you just want to do away with the png provided by the launcher all together and have it take the iphone icon from the website and make that the shortcut image? Sounds like a fairly simple task. I can't do it, unfortunately. But it sounds like it can be done quite easily. Someone will surely pick this up eventually
BetterBookmarks
BetterBookmarks in the Market does this already. I'm not sure if the functionality is exactly what the original poster is asking for, but I think it's pretty close. Check it out- http://www.cyrket.com/package/com.android.BetterBookmarks
It's been out for quite a while, and I'm not sure how accurate the app is at finding the icons for iPhone OS anymore. From my experience, the output of the shortcuts aren't as pretty as they would be in iPhone OS, but they're a lot more functional than the default website shortcuts.
Many favicons have multiple sizes embedded for this very reason. Would be nice if the launchers could just use the bext quality one.
I had a problem with BetterCut whenever I changed the icons for bookmarks, they'd stop working.
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
R3nrut said:
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
Click to expand...
Click to collapse
What the geeze.. gimme a sample? plz?
...how to hide from appdrawer..?
R3nrut said:
I just make my bookmarks into programs. Not recommended for the everyday user but it looks nicer to me and I have more control.
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
This is all the code required to click on the icon and start the browser. Easy as pie. You can drop whatever .png icon file you have into the /res folder and name it icon.png. That's all there is to it.
Click to expand...
Click to collapse
How about a complete sample source code? =)
maxisma said:
How about a complete sample source code? =)
Click to expand...
Click to collapse
Sure, its way simple though.
Code:
package com.bookmark.r3nrut;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class bookmark_r3nrut extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://r3nrut.com"));
startActivity(myIntent);
}
}
Anyone interested in helping me tackle this?

[TUT] Extend your HelloWorld App Step by Step with a Toast Message

Hi guys, this Tutorial is mainly intended for looking into some other concepts like GUI of Android development. The concept of "Toast" would be actually covered.
First you have to do this (Create a HelloWorld app) : [TUT] Making a HelloWorld App Step by Step w/pictures. - Tutorial created by rezo609
After you've created your first HelloWorld app, its time for some additional tasks!
(NOTE:- Make sure you've set your AVD already)
I know some of you guys are wondering what a Toast is, well here's the answer: Click Me!
Starting development :
Step 1: The first thing we are going to accomplish is changing the strings.xml (Path:- AppName > res > values > strings.xml) file to add another node under app_name. We will do this by copying the node above it and pasting the copied material directly under the last </string> element. Then we will change the name of the string to press and in between we will write Press Me!. Next we will alter the hello node and change the text to say Enter Your Name Here: instead of Hello Android, Hello World!.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click to expand...
Click to collapse
Step 2: Next step, is to design the GUI (Graphical User Interface). To do this navigate to main.xml (Path:- AppName > res > layout > main.xml) and we are going to go over what everything does up to this point. Set your main.xml file as shown in the below picture.
Make sure you've set the Orientation as vertical, otherwise ie, if its horizontal maybe the GUI controls won't be shown when the app is run.(in an HVGA Emulator, or maybe its me) Anyways you are free to toggle between vertical/horizontal and see what happens.
Click to expand...
Click to collapse
Step 3: Now this is a tricky step, and it includes Java code modifications. I suggest you to google to know exactly what all these codes means be it functions, classes, methods, objects or imports. You can refer the Wiki or the Oracle docs if you want to learn more about Java. Anyways for keeping this Tutorial simple, just modify the Java file (Path:- AppName > src > com.example.helloworld > HelloWorldActivity.java) as shown in the below picture.
I'll also give it as CODE, but don't just copy-paste. If you run into massive errors or problems only, do that. Its better to type the codes by yourself and see what all AutoFill options/suggestions are given by Eclipse. Anyways try to correct the errors by yourself, it maybe only a spelling-mistake, but you have to identify it where.
Code:
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.view.View.OnClickListener;
import android.content.Context;
import android.view.View;
public class HelloWorldActivity extends Activity {
EditText helloName;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Capture our button from layout
Button button = (Button)findViewById(R.id.go);
// Register the onClickListener with the implementation above
button.setOnClickListener(maddListener);
}
// Create an anonymous implementation of OnClickListener
private OnClickListener maddListener = new OnClickListener() {
public void onClick(View v) {
long id = 0;
// Do something when the button is clicked
try {
helloName = (EditText)findViewById(R.id.helloName);
Context context = getApplicationContext();
CharSequence text = "Hello " + helloName.getText() +"!";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
catch(Exception e) {
Context context = getApplicationContext();
CharSequence text = e.toString() + "ID = " + id;
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
};
}
Click to expand...
Click to collapse
Step 4: After doing all these above mentioned tasks, its time for the output. Be sure to click "Save All" (Ctrl+Shift+S) button in the Eclipse. Also make sure your Project is free from errors, otherwise it would not run. You can also clean your Project (Some errors maybe automatically fixed) by navigating to Project > Clean...
Right Click your Project > Run As > 1 Android Application
Your Emulator would start, and you'll see in the Eclipse as apk installing, running etc..
If your Project is a Success, you'll get the output as shown in the below picture:
Click to expand...
Click to collapse
And that's it
I hope you enjoyed this tutorial. Its made as simple as possible and omitted some theories from the Original source. You can get to it, and see the xml parts explained.
After you have succeeded in this app, head over to next Tutorial : Create your First Widget Step by Step
Thanks for this.
This is great!!
Sent from my HTC Wildfire S using xda premium
Welcome guys, hope you guys tried/will try and get successful.
Tutorial now featured at XDA-Portal : Here
Thanks to the Author.
So I decided to look at this. I've got everything as you have above but I have errors.
Current errors are in the following lines:
Code:
Button button = (Button)findViewById(R.[COLOR="Red"]id[/COLOR].go);
Code:
helloName = (EditText)findViewById(R.[COLOR="red"]id[/COLOR].helloName);
The error states: id cannot be resolved or is not a field
If I follow the listed fixes it places lines in the R.java. However, I then get errors on go and helloName for which there are no listed fixes.
Still looking to see if I can find it myself but wanted to tell you about this to see if it was just me (probably) or a missing section in the info above.
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.
blazingwolf said:
So I decided to look at this. I've got everything as you have above but I have errors.
Current errors are in the following lines:
Code:
Button button = (Button)findViewById(R.[COLOR="Red"]id[/COLOR].go);
Code:
helloName = (EditText)findViewById(R.[COLOR="red"]id[/COLOR].helloName);
The error states: id cannot be resolved or is not a field
If I follow the listed fixes it places lines in the R.java. However, I then get errors on go and helloName for which there are no listed fixes.
Still looking to see if I can find it myself but wanted to tell you about this to see if it was just me (probably) or a missing section in the info above.
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.
Click to expand...
Click to collapse
please check the imports ...
if you find line import android.R; ... remove it and then clean build....
blazingwolf said:
EDIT: Sigh. It's amazing what missing one line will do to you. This was my fault. Forgot to add the Press me string and it created these errors. Working great now.
Click to expand...
Click to collapse
There you are
Actually we should edit all the XML files first like android:id="@+id/go" and it will show error in XML file for sure (Because id can't be found anywhere) but finally when you code the java file, and when the id is referenced, all errors will be gone
Anyways the R.java file can't be modified manually. It will revert back to original state if you do so, that is even if you apply the suggested fixes by Eclipse.
pmapma1 said:
please check the imports ...
if you find line import android.R; ... remove it and then clean build....
Click to expand...
Click to collapse
Actually unnecessary imports will not cause the application to malfunction. It will only use more resources based on program. Eclipse will give a warning to remove unused imports, as its not used anywhere.
Hi there,
I've been wondering this so I thought I'd ask here since it seems nice and n00b friendly ;-)
I was wondering if you could tell me if there's any direct benefit to creating an OnClickListener in Java instead of using the android:OnClick="" attribute for the layout and having it go to a specified method.
Thanks,
Tom
TommiTMX said:
Hi there,
I've been wondering this so I thought I'd ask here since it seems nice and n00b friendly ;-)
I was wondering if you could tell me if there's any direct benefit to creating an OnClickListener in Java instead of using the android:OnClick="" attribute for the layout and having it go to a specified method.
Thanks,
Tom
Click to expand...
Click to collapse
Benefit?! ... Hmm !!
It all depends upon the logic of the programmer that he/she is comfortable with. Actually there will be many methods or many ways we can create for the same process. But as this is just a Tutorial/Illustration application, we don't know exactly what its effects. Maybe in real time application there maybe some beneficiaries. Just we need to sort it out to know.
can you make a tutorial how to make a background process? Or service of somekind.
E.g. process that shows blue led while BT is on
thanks in advance!
Shmarkus said:
can you make a tutorial how to make a background process? Or service of somekind.
E.g. process that shows blue led while BT is on
thanks in advance!
Click to expand...
Click to collapse
I'll definitely try, but can't guarantee when because I'm also a learning candidate in Android app development. So making Tutorials, that I've already learned and tried. Once I've learned about it, I'll of course include the Tutorial for it.
why we need try/catch for one-way trigger? ... what in toast can throw exception?
Flowyk said:
why we need try/catch for one-way trigger? ... what in toast can throw exception?
Click to expand...
Click to collapse
Well, I just checked myself by removing the try-catch block, and yes you are right as no exceptions are actually caught. Anyways the code is not actually written by me, and if you checked the original source you'd have known that.
And Thanks for the point mate. Maybe I'll review the code from next time onwards.
np ... im just learning
Error?
FIXXED

[Guide} [Basic] App development basics and first android app fully functional

This is basic guide to start to off app development for android..........
This is just a basic guide and not a comprehensive one which covers the whole lot of it but a rather a guide to get a basic simple app of your own running without any issues
Requirements
A bit of java
linux , darwin or a windows 7 machine
internet connection
basic idea of how programming works
sdk with atleast one api installed and configured path
Part 1 setting up everthing and explaining used variables and terms
Now let's get started
[windows}
Download eclipse as any other software and install it by the .exe file and follow the instructions
(linuc macosx )
if you are on a older ditribution of linux the minimum required version of eclipse 3.6 is not supplied via ubuntus main repository ....
so you need to download it from the eclipse official website and install it....
[common}
Installing ADT(Android developer tools) plugin
open up eclipse
Start Eclipse, then select Help > Install New Software.
Click Add, in the top-right corner.
In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
Click OK.
If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
In the next window, you'll see a list of the tools to be downloaded. Click Next.
Read and accept the license agreements, then click Finish.
If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
When the installation completes, restart Eclipse.
Configure the ADT Plugin
Once Eclipse restarts, you must specify the location of your Android SDK directory:
In the "Welcome to Android Development" window that appears, select Use existing SDKs.
Browse and select the location of the Android SDK directory you recently downloaded.
Click Next.
If you haven't encountered any errors, you're done setting up ADT and can continue to Next Steps.
the path to the sdk is case sensitive and absolute so be careful guys....
Now you have virtually everything set up to start building apps
go to file>new>project>android>android application project
something like this will pop up
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
now
the first three fields are yours to choose
now the second part
The build sdk is the sdk that you are targeting in laymans words its like building a building on a certain specific site.....
the minimum required sdk
now if choose this as froyo(api 8) your app will run on froyo os and above and will be compatible with older flavours of android....
once you are done creating a new project hit finish
now you will see something like this
now the calculator is my app name the name that you gave a few minutes ago will be yours...
Now the android is basically divided into three main things
The android manifest
The src folder
The xml
The android manifest basically is a traffic police in lay mans words
it determines which activity comes first when it ends etc...
note:i will be referring the xml to a activty
the src folder contains all of your java
xml's are the skeltel system of android they define the size layout colour or the whole look of your android project....
Note: dont tinker with the gen folder you alone will be responsible for your mistakes
in this tutorial you will be working with only src,res and xml's as i cant dig deeper into it because its a subject too broad to teach....
now lets get started
navigate to res > layout double click on main_activty.xml
below the screen click on activty_main.xml next to graphical layout...
something like this will appear
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
this is the text appearing to you
Note this is auto generated....
now i will explain each line of it with my limited knowledge
HTML:
]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
This is the auto generated refernce by eclipse yours may vary and might not be same as mine
HTML:
android:layout_width="match_parent"
android:layout_height="match_parent"
now you can see that the layout is set to match_parent by deafult
match_parent utilizes the whole screen into your layout...
and observe this guys the
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
the relative layout has started with <relativelayout and ended with > anything code started should be finished up by > or />
both are literally same
now the next junk of code to deal with
HTML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
Textview is basically a method by google to display some text on the screen...
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
These two lines suggest that your app has both vertcal and horizontal layout
android:text="@string/hello_world"
this is the text being displayed on your graphical layout
now go to layout > values > strings.xml
double click it
you will see something like this
now basically strings are resource files used to show text on display...
the string name cant have any spaces if it has then u will see errors
but the value of the string can have spaces
Activity
change the text in value field and see the result in graphical layout of the xml
now you basically need to use strings for each and every text that has to be displayed.......
End of part 1
Part 2
Adding of buttons and modifying them
now guys lets add some buttons to our project
navigate to src
in that you will find a java file open it (.java)
you will find something like this
HTML:
package com.exmple.addandsubract;
import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Layout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_layout, menu);
return true;
}
}
now you might be wondering what is this crap code ...
now lets add buttons
navigate into layout open up the xml
your screen will show up this
HTML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
now within the closing of relative layout
copy paste this
HTML:
<Button
android:id="@+id/bsub"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="79dp"
android:text="@string/sub" /
every button must have an id for our convenience we have added a bsub as our program is to add and subtract a number
HTML:
android:layout_width="match_parent"
the layout width specifies the size of the width of the button
as i have said before match_parent is to occupy the whole screen..if you want it smaller you can set it in dp(density pixels)
HTML:
android:text="@string/sub"
you cant hard code stuff into the button u need to refernce it to a string i have referred it to the string sub
for this to work it requires you to add a string by the name sub in strings.xml
now do the same code again for button add
after this you will have something like this showing up
now that we have our button's set up we need to make this work (in real add java to it)
to accomplish this we need to link xml's to java
this may sound like greek and latin but guys stick with it u will understand everything
now below
HTML:
public class Layout extends Activity {
type this
HTML:
int counter=0;
Button add,sub;
TextView display;
as u may all know we should define a variable before we use them
as we are working with number (basically integars we use integar to define them
now we basically define display as textview
now coming to the real java part
HTML:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);
after this chunk of code
type
HTML:
counter=0;
the counter is the number which should be displayed on the screen for us
i have decided to start with 0 you can set it to any number that you prefer
now type this
HTML:
add = (Button) findViewById(R.id.badd);
sub = (Button) findViewById(R.id.bsub);
what this basically says is that add is a button and its id(in the xml) is badd.. findviewbyid is the method for referencing
now its the same for sub button too
HTML:
display = (TextView) findViewById(R.id.textView1);
this will set our display to textview1 which is our activity.xml this may sound as bloat to you but its handy when working with many xmls
now type
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
display.setText("Your total is " + counter );
}
});
i will explain what this does
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
display.setText("Your total is " + counter );
}
});
type add. then all lists will popup select onclicklistener(this makes the button clickable)
within the brackets of onclicklistener type new(as its a new button) leave a space type view.onlclicklistener(again you will see popups
now what is between this two brackets is what happens when the button is clicked now add this in between these brackets
HTML:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter=counter+1;
display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter=counter-1;
display.setText("Your total is " + counter );
}
});
HTML:
counter=counter-1;
this decrements the counter value by 1
after the counter is decremented we need to change the display to show the value of it
we do that by typing this
HTML:
counter=counter-1;
display.setText("Your total is " + counter );
now do this for both buttons test the app on emulator
Have doubts comment below
liked the thread rate it that gives me moral confidence and motivation
1st reserved op has plans of increasing
reservation
2nd
one final one for the day... :cyclops:
thanks! :good:
its to the point and very precise!
View attachment HelloWorld.apk
how do i add an icon? mine is the default andy.
And is it possible to open an app (eg launcher pro) in eclipse and mod it as per my wish?
Harryhades said:
thanks! :good:
its to the point and very precise!
View attachment 1401833
how do i add an icon? mine is the default andy.
And is it possible to open an app (eg launcher pro) in eclipse and mod it as per my wish?
Click to expand...
Click to collapse
There are two ways to add icon after giving the package name in the next menu you can change the icon....or go re drawabl-hdpi and replace the icon.png by the one that u want it should be case sensitive and it should be the same text....
For the 2nd question
yes you can mod these apps i have tried adw from cm'r repo but it should work with launhcer pro to btw the app has to deodexed.....
Thanks
Thanks bro i have started developing one :good:
completing the guide this sunday
I realize this is a few years old but I'm new to developing apps and I been trying to get this to work so that I can add a number to a number stored in a database. The number is put in the database via "edittext". When I try this my number gets replaced with "false" when I hit the add button.
Sent from my LG-LS995 using XDA Free mobile app

[EDUCATION] - Algoid - Learning programming with turtle and smart language !

Everyting is on the title.... lol.
Let me present you my app Algoid.
First, Algoid is a programming language designed to simplify the self apprentiship of programing. (but not at all, it is a multi-paradigm scripting language : imperative, functional (anonymous function, class first function and recursive), OOP (prototype based, multi-inheritance), Meta Object Protocol and nativelly AOP)
Second, Algoid is an IDE to edit the AL Script code with auto-completion, code snippets, formating, DEBUGGER and STEP by STEP execution mode.
Third, Algoid is a set of online documentation / tutorials directly available on the app, with automatic copy of example and exercises source code.
This is some screen shots of the app:
It is a beta version, but nearly become an 1.0 version (06th of marth, to offer to my son, it is his birthday)
Available here:
play.google.com/store/apps/details?id=fr.cyann.algoid
I hope you will enjoy it !
This is an example to demonstrate the language (functional) capabilities.
Parse a csv file on only one line of code (developpers will love it)
PHP:
set csv;
csv = "data 1.1; data 1.2; data 1.3; data 1.4\n";
csv ..= "data 2.1; data 2.2; data 2.3; data 2.4\n";
csv ..= "data 3.1; data 3.2; data 3.3; data 3.4\n";
csv ..= "data 4.1; data 4.2; data 4.3; data 4.4\n";
set values = csv.split ("\n").each (function (item) {
return item.split (";").each(function (item) {
return item.trim();
});
});
values.eachItem(function (item) {
util.log ("parsed data : [" .. item .. "]");
});
And what about Aspect Oiented Programming with Meta Object Protocol :
PHP:
set superO = object () {
set superMeth = function (s) {
util.log ("Execute SUPER method with param : " .. s);
};
};
set o = object (superO) {
set meth = function (s) {
util.log ("Execute method with param : " .. s);
};
};
set logger = function (s, decored) {
util.log ("Before decored execution");
decored(s);
util.log ("After decored execution");
};
set myO = new o;
myO.setAttribute("meth", myO.meth.decorate(logger));
myO.meth("Hi I am algoid !");
util.log ("--------");
set myO.superMeth = myO.superMeth.decorate(logger);
myO.superMeth("Hi I am algoid !");
This is some screen shots of the app:
Play Store
Available here:
I enjoy you will like it
Hi everyone,
This is the last beta version before release.
I have to speed up, the birthday of by son is in j-8.... I have 2 or 3 little things to tune yet.
Well so new version with parser example.
Play with it, it demonstrate the power of AL isioms like cascade + functionnel.
The language is able to parse CSV (with delimiter or not) in only one line.... great class (when I think the number of time I have done this in my job).
The ; at the end of line become completly optionel. My backtracking parsing expression grammar is really powerfull, it has no problem this that.
v0.4.5 BETA 23-02-2013 Last beta version before release
- new AL features examples (AOP, ducktyping, parsing, lexical closure)
- the end line semicolon is now totally optional
- array keyword is mandatory for the first one in nested arrays
- menu organisation
Well, for next version, I am working on monetizing the app. But I don't know how to do that without changing user experience.
I anyone has an idea.
So, you can find it here....
Have a nice week-end
Little question ???????
I'm thinking about the future of the app. What would you prefer as libraries:
- Gui
- Game
- Mindstorm
- Device capabilities (GPS, Gyro, Camera ect ....)
Please do not hesitate to reply.
CyaNn said:
Little question ???????
I'm thinking about the future of the app. What would you prefer as libraries:
- Gui
- Game
- Mindstorm
- Device capabilities (GPS, Gyro, Camera ect ....)
Please do not hesitate to reply.
Click to expand...
Click to collapse
looks great , and getting great reviews on play! i will return tomorrow with double thanks ( just ran out of thanks credit! )
# for me ... maybe 1 & 4 ... muchas gracias
v 0.4.5
# 1 & 4
This is great, even wife found this interesting.
Best wishes to your son!
cheers
biopsin said:
# 1 & 4
This is great, even wife found this interesting.
Best wishes to your son!
cheers
Click to expand...
Click to collapse
Thanks a lot for your replies.
Unfortunatelly, my wife does not find it interessting.... lol.
So at the moment, the score of the suvey is :
At the moment :
gui & device capabilities : 4
game : 7
mindstorm : 0
poor mindstorm....
Hello everybody,
With great excitement, I announce the official release of v1.0 Algoid.
Algoid become a donateware, free without ads, but donate if you decide that this project is worth and helpfull.
I think it is the better choise for this kind of project.
Well, I hope you will love it.:good:
Where or how can i learn this language?
Sent from my ST18i using Tapatalk 2
Hi there.
A little up to version 1.0.1 to correct a crash on certain little device (sorry for that)
Peace an code. :highfive::silly:
CyaNn
matgras said:
Where or how can i learn this language?
Sent from my ST18i using Tapatalk 2
Click to expand...
Click to collapse
Everything is on the App.
On bottom part of the screen (on splitted view), you have tutorials, language reference and inapp forum.....
best
CyaNn :cyclops:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
jasonxD said:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
Click to expand...
Click to collapse
Do you had any problem with the app ?
If yes, please indicate me : the app version, after what action it crash. Then I can correct it.
Thanks :crying:
jasonxD said:
Force Closes
I Will Not Keep Calm So You Can STFU and GTFO
Click to expand...
Click to collapse
Keep cool ! :angel:
I think I have found your problem.
You have downloaded the app at 7:48 (10 minutes after I have published the app on the store) and play store take one hour to really publish the app.
So I think you have tried the 1.0.0 version which have a serious problem of crash at startup with certains devices : GT-S5360 and GT-S5570I
the v1.0.1 version was published to fix this bug. So I think you can try it again with the new version of the app (of course if you are interested)
Have a nice week-end :angel:
Some preliminar benchmarks of AL on MacOS (quad core duo)
- Python is 2.6.1, it is an interpreted language over c++
- JavaScript / Rhino is a java on the fly compiled language (I have put the optimization to maximum)
On Android platform, Javascript should have some worst performances because it cannot generate bycode yet (due to dalvik different nature than JVM)
- AL from Algoid is my pure java interpreted language
As demonstrated, AL has similar performances than python except for object creation. I don't have solution for that yet. Perhaps in a future version.
So I am excited to see what it will done on Algoid with 3d cube
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
All these tests was realized by looping each instruction 1'000'000 times. For object creation only the instruction was executed only 10'000 times.
As until does not exists on Python an equivalent was scripted (while (True) : if (cond) break)
This last month was really hard and tedious. But it was for a good cause. I have completely re-write the AL language implementation to improve drastically performances.
And what is going on beyond my expectations: 10x to 40x faster than previous version. Faster than Javascript / Rhino (about 2x).
Unfortunately slower than Python and Lua on android only. I think Dalvik VM is not as optimized as JVM is because on my MacOS AL have same performances than Python....
Nevermind ! Try to execute the 3d cube or space invader.... These programs seems to have drank too much coffy !!!! lol.
Further, you have been a lot to vote to game developpment framework !
The developpment of a game edition of this app has started.... To be continued....
hehe, I return to my weekly update frequency.....
This is the new v1.1.2 release with
- correct several scope bugs in language
- show AL exception in source code instead of unhandle exception
- algo.curve and algo.curvedPoly
- two another 3d example : 3dAlpha and 3dSpline
I hope you will like it
Find it here :
Well, I just hope it really is "child-friendly" because, though interested, I barely know anything about programming. Trying it now.

Categories

Resources