I'm developing chess game for Android (androidchess.appspot.com). If I want to add animations, should I use custom View extending Canvas (I do this now), or custom View extending SurfaceView?
i am developing an android todo list app to learn. right now in my main layout xml file, i list all to-do list items. i created a menu button called add to add a new to-do. the problem is that i want to show a different view when add button is pressed. in that view i will have an editbox and 2 buttons. anyone have any suggestion on how that can be accomplished?
Hi All,
I want to create a list view custom like this link : http://sites.google.com/site/androideyecontact/_/rsrc/1238086823282/Home/android-eye-contact-lite/eye_contact-list_view_3.png?height=420&width=279
so far I have made a list view with text, and I am not extending list Activity, but I am extending Activity only.
please if someone can provide me with a code for this.
Thanks alot
Cheers
Kai
Here is my custom adapter:
...
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(android.R.layout.simple_list_item_checked, parent, false);
return v;
}
...
Now this visually appears to be exactly what I needed. The problem is that I can't get toggle the checked state when I click on the listview item. Any solutions?
This has been killing me for two days now. I have a main Activity A which calls a second Activity B. Activity B simply presents the user with a listview. When I press an item on the list view I want a couple of strings to be passed back to the main Activity A and Activiy B will finish.
The problem is I always get a resultcode of 0 and the data bundle is null. I really don't understand why this is happening.
Here is my code.
Start Activity B for result;
Test.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(recipeActivity.this, BrowseLoadRecipes.class);
startActivityForResult(i, RECIPE_CHOOSER);
}
});
This starts the second Activity fine. Activity B populates a listview and when I click an item I'm trying to send some data back to the calling Activity A.
Any text at the moment, so I used the following in Activity B;
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Bundle bundle = new Bundle();
bundle.putString("TEXT", "Please work... pleeeeaasee");
Intent mIntent = new Intent();
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}
});
In the calling activity I have the following listening for the return as follows;
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
switch(requestCode) {
//TODO
case RECIPE_CHOOSER:
Toast.makeText(getApplicationContext(), "In recipe return", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "resultCode is " + String.valueOf(resultCode), Toast.LENGTH_SHORT).show();
if (resultCode == RESULT_OK) {
Bundle b = getIntent().getExtras();
Toast.makeText(getApplicationContext(), "Returned " + b.getString("TEXT"), Toast.LENGTH_LONG).show();
}
if (resultCode == RESULT_CANCELED) {
}
break;
}
}
}
I can see that the request code is correctly returned, but the resultcode is always a 0 and the data is always a null.
I've ran through the debug and the setResult is doing its job and the bundle does indeed have the data I'm passing, but it's lost at some point along the way.
Is there something in the manifest I'm missing or something. It's killed my progress on this project so far.
Any help would truly be appreciated.
Thanks,
Dean
Hi everybody,
I want to have a view with several choices when I click an element of my ListView. I was thinking of implementing an AlertDialog but as I need more than 3 options it is not possible...
I also thought of putting my ListView in a FrameLayout and have an view with a gone visibility that I would turn visible at the click and update the content but I don't know If it's a good idea.
I could do with some advice,
Thanks for any idea.
In my application I detect the out going call when a call is dialled from the dialer or contacts.
This works fine and I then pop up a dialog saying I have detected the call and then the user presses a button to close the dialog which calls finish() on that activity.
It all works fine except that when I then hold the home key to bring up the recently used apps the dialer icon is there.
And when it is clicked the dialog is brought back into focus in the foreground when the dialog activity should be dead and gone and not be able to be brought back to the foreground.
Here is a picture of what I mean.
So two questions arise, why would the dialer icon be getting placed there and why would it be recalling my activity to the foreground?
Here is the code for that Activity which has a dialog theme:
public class CallDialogActivity extends Activity{
boolean isRecording;
AudioManager audio_service;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
audio_service = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Bundle b = this.getIntent().getExtras();
String number = b.getString("com.networks.NUMBER");
String name = b.getString("com.networks.NAME");
TextView tv = (TextView) findViewById(R.id.voip) ;
tv.setText(name);
Intent service = new Intent(CallAudio.CICERO_CALL_SERVICE);
startService(service);
final Button stop_Call_Button = (Button) findViewById(R.id.widget35);
this.setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
stop_Call_Button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent service = new Intent(CallAudio._CALL_SERVICE);
//this is for Android 1.5 (sets speaker going for a few seconds before shutting down)
stopService(service);
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(setIntent);
finish();
isRecording = false;
}
});
final Button speaker_Button = (Button) findViewById(R.id.widget36);
speaker_Button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
if(true){
audio_service.setSpeakerphoneOn(false);
}
else{
audio_service.setSpeakerphoneOn(true);
}
}
});
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
public void onCofigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
It calls a service that uses AudioRecord to record from the Mic and AudioTrack to play it out the earpiece, nothing in the service to do with the dialler.
Has anyone any idea why this might be happening?
(Newbie to Java, old time C# guy.)
I have noticed a lot of the use of @Override in Android example code. I thought that all Java methods were by default "Virutal"?
What then does @Override do?
Example:
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
I need to create a home screen (menu) with four to six items arranged in a grid view, each item needs to have an icon and a text below the icon. I googled and everything I could find were adapterView examples, with dynamic menu loading, and I want to make it with static xml, this view will not change so no need for dynamic code.
Can anyone post an xml example of this?
Android: How to Add Static row in list view
I have a requirement where i need to add the Static row as first row in list view
Thanks in advance for help..
Hi,
I have a ListView in my android application.
If I flick up/down the ListView, which method will return my 'selected' element in my list View? How about if I use the track ball to navigate up/down my list view, which method will return the index of my selected element?
Thank you.
assuming i want to open another activity from my current activty and i want to pass her arguments such as in my case diffculty level how i do it?...
newGameButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Intent i = new Intent(countryCityGameMenu.this,GameScreen.class);
startActivityForResult(i, GlobalDataStore.STATIC_INTEGER_VALUE);
}
});
is there a way to pass those arguments in the calling ?...
thankx
Hi folks,
In web view, the overview mode method does not works in Android 1.6. Because of the API Level restrictions. is there any possible to show the web view in zoomed out completely? Any Idea?
WebSetting.Zoomdensity is available in API Level 7 only.
I have to dynamically add a list of views (the views use RelativeLayout). Can I do this by specifying the view definition in xml and instantiate multiple objects off it? This gives the usual benefits of separating the view part from the code (for e.g., making it easy for the UI guys to alter things) or Is going the ArrayAdapter the suggested/only route?
I have an android application in which once when I call requestFocus() to a view I want to go to that view in an animated way (for eg: in an accelerated way, or a slow animation). All my views are in a ScrollView.
Hi!
I have an Android TextView where the view itself is limited to four lines. If the text exceeds this limit I want the end of the view to end with something like .. <-- to notify that there is more text here so you can click and open in fullscreen for example. Not just suddenly stop in the middle of a sentence. Is there a quick fix for this?
When i click on GO button its not taking to next Activity. I am using the following code.. can any one correct me where am i going wrong?
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
startActivity(new Intent(currentActivity.this, NextActivity.class));
}
});
This week we take a look at tweaking the Window’s start menu search for fast and focused searching, locking down a hyperactive Android screen, and fueling your torrenting habit through Dropbox.
Once a week we dip into our reader mailbag to help readers solve their problems, sharing the useful solutions with you in the process. Read on to see our fixes for this week’s reader dilemmas.
Latest Features
How-To Geek ETC
Inspire Geek Love with These Hilarious Geek Valentines
How to Integrate Dropbox with Pages, Keynote, and Numbers on iPad
RGB? CMYK? Alpha? What Are Image Channels and What Do They Mean?
How to Recover that Photo, Picture or File You Deleted Accidentally
How To Colorize Black and White Vintage Photographs in Photoshop
How To Get SSH Command-Line Access to Windows 7 Using Cygwin
Amazon Finally Adds Real Page Numbers to the Kindle
Now You Can Print Google Docs and Gmail through Google Cloud Print
AppBrain Enables Direct-to-Phone Installation Again
Build a DIY Clapper to Hone Your Electronics Chops
How to Kid Proof Your Computer’s Power and Reset Buttons
Microsoft’s Windows Media Player Extension Adds H.264 Support Back to Google Chrome
My name is Robert, I am an Android programmer and wanted to show off my latest project - a 2d game engine.
You can see it in action here - https://play.google.com/store/apps/details?id=engineDemo.com
My engine's main advantage is its ease of use. To have your level up and running, you'll need only 3 lines of code.
ABoxView aboxView = new ABoxView(this);
setContentView(aboxView);
aboxView.loadLevel("level/level02");
Level are created in a special level constructor and object physical properties are stored in a corresponding XML file.
I am looking to cooperate with those, who might be interesting in using my engine in their games. You can email me at [email protected] or post here.
Thanks,
Robert
Environment: Ubuntu 10.04 (64-bit), Eclipse Helios 3.6 (64-bit), Android 2.3 SDK + ADT.
All works great, but I can only select a workspace that's on the local system. Eclipse won't let me select shared folder on a Samba server.
Ubuntu's URI for this share is of the form:
smb://[email protected]/sandbox/workspace
But even if I typed this manually into the edit box, Eclipse won't accept it.
I don't have this problem with Eclipse 3.6 on Windows.
Is there a workaround to solve this?
I have dedicated past few month to developing my own android 2d engine.
You can see its description, demo and tutorials here http://www.aboxengine.com/ ( jar files will be up in a day or two ).
While working on the engine I believed it to be better then most available alternatives ( such as andengine, etc. ) and that people would love to use it in their games and, hopefully, would give me some royalties.
Yet as I started posting about my engine on other forums, it start looking like people are only interested in free/opensource engines.
Based on your experience, what do you think, is there some way for me to make money with that engine or should I forget about selling it and more focus on making games with it myself?
Thanks!
I making a 2D game for Android using OpenGL-ES technology. It is a space shooting game where the player shoots enemy ships.
I want to keep a track of score for the amount of enemy ships destroyed and a record of a local highscore. The score should be incremented whenever an enemy is destroyed. I also want a way of displaying both the current score and highscore on the game screen. I am not familiar with databases at all and I will appreciate a clear answer or a link to a good tutorial for my cause. Thanks.
I've been developing non-mobile apps for linux; mainly stuff like interpreters, compilers, database engines and business apps.
I've been told that if I wanted to learn how to develop iPhone/iPad applications, I should buy a Mac since Apple has all it's development tools for iPhone/iPad on Mac.
Now, what about Android phones / tablets? Are the development tools better on Mac or PC?
I need to buy a new laptop, and I would like to factor in mobile development in my choice of PC or Mac.
In an Android Java project, there are two folders, asset and res. To me, I usually put some stuffs, like PNG files, sound files, etc. in either one of the two folder. When resources are increasingly becoming more and more in those folders, the time it takes to load them will increase. Therefore, a loading screen is a must in these situation.
The total size is to be used in a loading screen, so that I can guess the average time it takes to load each resources, from 0 bytes to its individual resource file size.
I only know that by adding all individual sizes in a respective order, I will then obtain the total asset or res folder size, simply by adding them up.
So, when it comes to getting the total file size from either folder, how do you obtain their individual resource/object sizes, respectively?
Thanks in advance.