AVD ignoring layout-large/file - android

I chose my emulator as a Nexus 7 through Android Studio.
It's size is "large".
But when I run my app on the emulator then it still prefers using the default "layout" folders resource files.
I tried using the "layout-sw600dp" qualifier but still with no luck.
The resource file in both layout folders have the same name "news_articles.xml".
See my basic code below:
public class MainActivity extends Activity implements HeadlinesFragment.OnHeadlineSelectedListener{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.news_articles);
}
What am I missing?

You should change in AVD Manager - Your Emulator Edit - Show Advanced Setting - Custom Skin Definition to "No Skin" and rerun the emulator.

Related

Controls showing in designer but not in emulator

This is my first Xamarin app. I have my environment set up in Visual Studio, and have a template project which I can run in the Android emulator.
Having dragged and dropped a couple of controls on to the designer surface, I find that when I run the application in the emulator, neither of the two controls that I have added (a button and a switch) display in the emulator.
I have tried:
Cleaning the solution
Rebuilding the solution
Manually deleting bin and object files
Unchecking 'Use Fast Deployment' in project Android Options
Uninstalling from the emulator
But with the same result each time.
[Project files removed]
Am I missing something?
Just downloaded your code and ran it. Uncommenting SetContentView (Resource.Layout.Main); it worked to me.
[Activity(Label = "Tgo.AndroidApp", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
}
}
Here a nice guide to get you started with Xamarin Android.
navigate to MainActivity.cs and uncomment this code
SetContentView (Resource.Layout.Main);
and rebuild the solution and debug.
Let me know it if helps!
In my case, I had to update my Main.xml file with the updates I put into the Main.axml and Rebuild.

Set a values folder for multiple android sdk versions

I would like to set a values folder for multiple sdk verions to set a theme for everything under sdk 19. I have tried doing:
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < 19) {
getApplication().setTheme(R.style.HomeTheme4);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_launch_screen);
[.....]
}
But this doesnt seem to set the theme For the whole app.
Thank you in advance.
you could place your theme that you want to use for API-19 and above inside the folder:
/values-v19
and the default values folder then will handle everything below API-19:
/values
see related android resource qualifiers documentation.

PreferenceActivity Localization

am working in a multi language Alarm android application with :
1 xml file [alarm_settings.xml]
2 string.xml files [English & arabic]
The problem is that the localization is not working in the right way, below you can find 4 images 2 for my application and 2 for the device's Settings
When you look at these 4 images you can find that in my application the localization works only for the text not for the alignment of views , but you can find in the device's settings that the localization works for both of them - text , views - .
So is it a special case for the device's settings views or i can make my views to be localized like the Device's settings ?!
.java File :
public class MainActivity extends PreferenceActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.alarm_settings);
}
}
thanks
Just found the Solution of the problem at Android Developers Blog
in my case it it was to add
android:supportsRtl="true"
to the element
application
in
manifest file.

How can I "preview layout" of an xml file on Android?

I am creating a bunch of layout files and would like to preview roughly what they will look like on the Android. Is there a way to do this? and if so, what would be the best way?
Right now, I have to boot up the device and navigate to the Activity every time in order to see the layout. Also, it looks like the preview of Eclipse is not ideal as it doesn't display things correctly (is this the best it gets?)
You can create a Dummy Activity, and set the intent MAIN to it.
When you want to test how that activity looks like, just setLayout on onCreate to the xml that you want to test and you will see it.
I also don't trust in Eclipse preview, and AVDs are really slow, so I attach an android device and use a dummy activity to test layouts
You can use the utility at http://www.droiddraw.org/.
Simply copy and paste your layout xml at the Output window, and click "Load". This works both ways.
Besides running on a real device or in the emulator, Eclipse's preview is the best it gets. Make sure you set the right options for screen size and API version in the preview screen; that sometimes helps.
You can create an Activity like this:
//add the imports
public class TestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Ask for a full screen window
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
/* (non-Javadoc)
* #see android.app.Activity#onStart()
*/
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
// Get the info about the screen
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Change the activity_main layout and you can test any layout clicking in Graphical Layout of your xml.
If you don't trust in Eclipse-preview and you want to avoid the slow Android emulator, try to enable the Virtualization (Intel processors). You must install the packages Intel x86 Emulator Accelerator (HAXM) and Intel x86 System-Image. Next, you can create an AVD using that System-Image and the emulator will speed up.
Otherwise, if you haven't got a capable Virtualization processor, I'm sorry for you, but you must trust in Eclipse preview ;)
Bye!
Add as parameter of ListView in xml file following line:
tools:listitem="#layout/my_custom_list_item"
where my_custom_list_item is layout you want to use as list item.

PhoneGap SplashScreen - splash cannot be resolved or is not a field

i want to make a splash screen on my android application, i use phonegap.
here is my main.java code :
public class App extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);
}
}
but i got an error : "splash cannot be resolved or is not a field"
i've put the splash.png on every drawable directories, but the error still there..
anybody could help me? thanks in advance..
I think there is an issue about the timeout parameter in your case 5000 and it was fixed in phonegap 1.6.0 release that's why you don't get it work:
these links confirms that
How to use OpenStreetMap/OpenLayers?
phonegap - splash screen for Android app
try to use the last phone gap release (1.8.1) and you will get it work
just change the word splash by screen:
super.setIntegerProperty("splashscreen", R.drawable.screen);
I was having a similar problem. I renamed the package which extended the core DroidGap class. My solution was fixed by this solution: http://www.youtube.com/watch?v=3CHRujojc2o. In short, make sure to update your references in the AndroidManifest.xml file to point to the new package name.

Categories

Resources