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.
Related
I want to know how to show the Unreal screen on Android's subview.
I apologize for my lack of English skills.
I want to show the Unreal screen in subView for Android-based projects.
I want to put it in a project created by a new project through Android Studio.
The start consists of Android native code, and several menus were all created using JetPack api.
Here, I want to configure the bottom with Android UI and the top with an Unreal screen.
Or, if you press the start button for UNREAL screen, I want to render the screen where the entire screen is UNREAL screen.
These two things should possible.
I knew how to do Unity.
Unity knows what is possible.
Is Unreal possible?
If possible, can I get help with the guide links such as documents and videos?
Try this as I assume that you have already added the Unreal Engine Viewport Client plugin to your project and that you have added a LinearLayout with the id
import com.epicgames.ue4.ViewportClient;
public class MainActivity extends Activity {
private ViewportClient mViewportClient;
private SurfaceView mSurfaceView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the Android View to display the Unreal Engine Viewport
mSurfaceView = new SurfaceView(this);
// Add the Android View to the layout
LinearLayout layout = findViewById(R.id.layout);
layout.addView(mSurfaceView);
// Create the Viewport Client and associate it with the Android View
mViewportClient = new ViewportClient();
mViewportClient.SetViewport(mSurfaceView);
// Configure the rendering settings for the Viewport Client
mViewportClient.SetResolution(1920, 1080);
mViewportClient.SetCameraPosition(0, 0, 1000);
mViewportClient.SetPostProcessingEnabled(false);
// Start the rendering loop for the Viewport Client
mViewportClient.Start();
}
#Override
protected void onDestroy() {
super.onDestroy();
// Stop the rendering loop when the activity is destroyed
mViewportClient.Stop();
}
}
Inside Google analytics admin section I created 4 custom dimension. 1st dimension scope is "user", 2nd, 3rd and 4th dimension's scope is "hit".
I set parameters inside my onCreate function and send them in onStart command of my Activity. But when I check custom reports, I see that 1st dimension is set correctly. But no data for other 3 dimensions. I tried different days and waited but no change. I can see 1st dimension's data successfully. How can I set these custom dimensions, what do I miss ?
#Override
public void onCreate(Bundle savedInstanceState) {
MyUtil.initializeGAtracker(mContext);
MyUtil.getGaTracker().set(Fields.customDimension(1), "aaa");
MyUtil.getGaTracker().set(Fields.customDimension(2), "bbb");
MyUtil.getGaTracker().set(Fields.customDimension(3), "ccc");
MyUtil.getGaTracker().set(Fields.customDimension(4), "ddd");
MyUtil.getGaTracker().set(Fields.SCREEN_NAME, "myscreen");
}
#Override
public void onStart() {
super.onStart();
MyUtil.getGaTracker().send(MapBuilder.createAppView().build());
}
I also tried this. But it didn't help:
MyUtil.getGaTracker().send(MapBuilder
.createAppView()
.set(Fields.customDimension(2), "bbb")
.set(Fields.customDimension(3), "ccc")
.set(Fields.customDimension(4), "ddd")
.build()
);
Is there a detailed resource for setting multiple custom dimensions ?
I only found this:
https://developers.google.com/analytics/devguides/collection/android/v3/customdimsmets
Edit: Documentation is not adequate, also custom dimensions documentation has syntax error.
The code that you provided should work correctly.
Can you provide more details on MyUtil class?
Do you see any errors in debug mode? The SDK should output a bunch of errors if there is something wrong.
The SDK also prints out the hits that it is sending over wire. Can you copy and paste one of such hits here?
Also, your code snippets do not show you setting the tracking id. Can you check that you have set the ID? You can set it in the xml config or in the SDK APIs.
I am trying to implement the example shown on this page. I have tried on three different devices running android 4 and above, and in all cases I get a black screen with this warning:
01-27 20:01:22.683: W/TextureView(4728): A TextureView or a subclass can only be used with hardware acceleration enabled.
I have turned on hardware acceleration in the application manifest:
<application
android:hardwareAccelerated="true"
[etc...]
But the following check my custom view's onAttachedToWindow method always returns false
private class MyTextureView extends TextureView
{
public MyTextureView(Context context) {
super(context);
}
#Override
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
Log.d("", Boolean.toString(mTextureView.isHardwareAccelerated()));
}
}
Does anyone know what is wrong here?
Thanks
If you testing with Emulator then please check configuration for hardware acceleration.
Please check this thread for more info:
http://developer.android.com/tools/devices/emulator.html#acceleration
What I need unless my tablet is connected to a server I cant have the tabs being changed. I have a tab host that is all run off of the same java file. I figure all I need to do is have some sort of a test in the file to say unless boolean is true dont let the code change the tab. However I dont know how to do this? If you need to see any of my code just leave that in the comment box. Thanks for all your help !
Well I guess you can try disabling/enabling clicks on the tabs by calling:
myTabHost.getTabWidget().setClickable(isConnectedToServer);
But I'm not sure that's good UX, how about letting your users change tabs, but if the content can't be reached displaying a message inside the main view of the tab "server unreachable, check your internet connection" or something like that.
UPDATE:
Try this instead (for each of your tabs):
myTabHost.getTabWidget().getChildTabViewAt(0).setEnabled(false);
myTabHost.getTabWidget().getChildTabViewAt(1).setEnabled(false);
myTabHost.getTabWidget().getChildTabViewAt(2).setEnabled(false);
ANOTHER UPDATE:
public class MyActivity extends Activity {
private TabWidget mTabWidget = null;
protected void onCreate(Bundle savedInstanceState) {
...
mTabWidget = myTabHost.getTabWidget();
...
}
protected void refreshTabs(boolean isConnected) {
mTabWidget.getChildTabViewAt(0).setEnabled(isConnected);
mTabWidget.getChildTabViewAt(1).setEnabled(isConnected);
mTabWidget.getChildTabViewAt(2).setEnabled(isConnected);
}
Now you can call refreshTabs whenever you want in your code to make them enabled/disabled.
I apologise if if 'hover assist' isn't the right terminology but I'm referring to the feature in Eclipse where if the use hovers the pointer over a method, a popup box appears with javadoc type information and invites the user to press F2 for focus. I see inconsistent behaviour for different methods, in that sometimes the browser gives me a file not found error when I click on a highlighted subject in that box.
I can best illustrate this by means of a snippet of code from a test project. I have the method:
#Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
... etc
...
}
If I hover over 'getSystemService' I see:
.
and then click on 'String' it takes me to the javadocs page
file:///C:/dev/tools/android-sdk-windows4.0/docs/reference/java/lang/String.html
on my machine in the browser. (I use the Firefox external browser) and this is just what I want.
However if I hover over the onCreate, I see:
Then if I click on the 'Bundle' link, I get this in the browser:
**File not found
Firefox can't find the file at /C:/dev/projects/EclipseIndigo/AndroidWorkTwo/CompassTwo/src/reference/android/os/Bundle.html.**
I have built the project with Android 2.3.3 jar and the javadoc properties show
which validates OK. I don't understand this inconsistent behaviour. Any help will be much appreciated.
The difference in both cases is the path "/docs/reference/java/" and "/src/reference/android/os/"
Please have a look at this url:
How to generate links to the android Classes' reference in javadoc?
It may guide you to correction.
Solved: I think it's just a plain Eclipse bug.
When I hover over the (overriden) onCreate the popup's header shows it belonging to my package and activity which extends Activity (as it must do)
If I click on the link inside the popup : Overrides: onCreate(...) in Activity
The the popup changes to show the same information but in class:
void android.app.Activity.onCreate(Bundle savedInstanceState)
Then, if I click on 'Bundle' in the new popup, all is well, we get the javadocs.
It's almost as if Eclipse thinks that the class Bundle itself has been overriden too and looks for the javadocs in my source.