Android multi window launcher sidebar - java

I want this drawerLayout(bellow photo) to always open like Samsung multiwindow sidebar.
Till now I am able to open this drawerLayout(sidebar) within the app. please give the instruction to be able to open this draweLayout(sidebar) from anywhere(I mean from any other app or even from home screen of a device).
Thanks in advance.
Here is my drayerLayout XML file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:background="#color/cardview_light_background">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swipe Right"
android:textSize="15dp"
android:textColor="#D50000"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Open App In\nMultiWIndow Mode"
android:textSize="30sp"
android:gravity="center"
android:textStyle="bold"
android:textColor="#color/black"/>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
tools:context=".MainActivity2">
<ListView
android:id="#+id/listView"
android:layout_width="280dp"
android:layout_height="0dp"
android:layout_marginStart="10dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>

This cannot be achieved by making something global you to do some modification in every activity
you can create a new class that will have a method to initialize the navigation, move navigation view to separate xml file and include that file in every activity, and call initialization method in every activity
You can try this library https://github.com/mikepenz/MaterialDrawer to move most xml code to java so you won't have to add DrawerLayout in every activity but choice is your, it always better to skip using 3rd party libraries if you can
if you are using library than here's some example you can follow
Constant.java
private void setupNavigationDrawer() {
ProfileDrawerItem section = new ProfileDrawerItem()
.withSetSelected(false)
.withSetSelected(false)
.withEnabled(false);
PrimaryDrawerItem joyType0DrawerItem = new PrimaryDrawerItem().withName("Basic Gamepad").withTag(KEY_BASIC_GAMEPAD_1).withLevel(2);
PrimaryDrawerItem joyType1DrawerItem = new PrimaryDrawerItem().withName("Assault Horizon").withTag(KEY_ASSAULT_HORIZON).withLevel(2);
PrimaryDrawerItem joyType2DrawerItem = new PrimaryDrawerItem().withName("Awesomenauts").withTag(KEY_AWESOMENAUTS).withLevel(2);
PrimaryDrawerItem joyType3DrawerItem = new PrimaryDrawerItem().withName("BombSquad").withTag(KEY_BOMBSQUAD).withLevel(2);
PrimaryDrawerItem joyType4DrawerItem = new PrimaryDrawerItem().withName("Final Fantasy XIII").withTag(KEY_FINAL_FANTASY_XIII).withLevel(2);
SectionDrawerItem sectionDrawerItem = new SectionDrawerItem().withName("Joystick Type").withTextColorRes(R.color.colorAccent);
PrimaryDrawerItem deviceDrawerItem = new PrimaryDrawerItem().withName("Device Connection").withTag(KEY_DEVICE_CONNECTION).withIcon(GoogleMaterial.Icon.gmd_devices);
PrimaryDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName("Settings").withTag("settings").withIcon(GoogleMaterial.Icon.gmd_settings);
ndMenu = new DrawerBuilder()
.withActivity(this)
.withToolbar(tbMain)
.withCloseOnClick(true)
.withFireOnInitialOnClick(true)
.withSelectedItemByPosition(6)
.withDelayDrawerClickEvent(300)
.withDisplayBelowStatusBar(true)
.withTranslucentStatusBar(false)
.withOnDrawerItemClickListener(this)
.addDrawerItems(section, deviceDrawerItem, settingsDrawerItem, sectionDrawerItem, joyType0DrawerItem, joyType1DrawerItem, joyType2DrawerItem, joyType3DrawerItem, joyType4DrawerItem)
.build();
findViewById(R.id.nav_button).setOnClickListener(new
View.OnClickListener() {
#Override
public void onClick(View v) {
// Check these functions from library example to check drawer state and open close drawer
if(ndMenu.isDrawerOpen){
ndMenu.closeDrawer();
} else {
ndMenu.openDrawer();
}
});
}
MainActivity.xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<include
layout="#layout/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout>
nav_view.xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
orientation="horizontal">
<Image
id="#+id/nav_button"
android:layout_width="30dp"
android:layout_height="30dp"/>
<LinearLayout>

Related

Adding a Button below a ListView in a ListActivity

I need a ListActivity with a ListView that has a Button below it. So you can scroll the ListView while the Button stays on the bottom. It looks fine in the layout but when i launch the app, there is no Button.
That is the XML of my ListActivity:
<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"
android:descendantFocusability="blocksDescendants"
tools:context=".PalettenActivity" >
<ListView
android:id="#+id/listViewPaletten"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/buttonPalettenBetaetigen"
android:entries="#layout/paletten_item"
android:minHeight="?android:attr/listPreferredItemHeight" >
</ListView>
<Button
android:id="#+id/buttonPalettenBetaetigen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="Bestätigen" />
</RelativeLayout>
Here's the code of the paletten_item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layoutPalettenItem"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
tools:context=".ChecklistAdapter" >
<TextView
android:id="#+id/textViewPalettenBez"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:gravity="left|center_vertical"
android:text="Bezeichnung"
android:textSize="25sp" />
<Button
android:id="#+id/buttonPalettenPlus"
android:layout_width="65dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:text="+"
android:textSize="20sp" />
<TextView
android:id="#+id/textViewPalettenAnzahl"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignBaseline="#+id/buttonPalettenPlus"
android:layout_alignBottom="#+id/buttonPalettenPlus"
android:layout_toLeftOf="#+id/buttonPalettenPlus"
android:gravity="center"
android:text="0"
android:textSize="20sp" />
<Button
android:id="#+id/buttonPalettenMinus"
android:layout_width="65dp"
android:layout_height="match_parent"
android:layout_alignBaseline="#+id/textViewPalettenAnzahl"
android:layout_alignBottom="#+id/textViewPalettenAnzahl"
android:layout_toLeftOf="#+id/textViewPalettenAnzahl"
android:text="-"
android:textSize="20sp" />
</RelativeLayout>
This is how i add the onClickListener to the Button in the onCreate() method of the ListActivity:
LayoutInflater itemInflater (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View convertView = itemInflater.inflate(R.layout.activity_paletten, null);
btnPalettenBestaetigen = (Button)convertView.findViewById(R.id.buttonPalettenBetaetigen);
btnPalettenBestaetigen.setText("Bestätigen");
btnPalettenBestaetigen.setVisibility(View.VISIBLE);
btnPalettenBestaetigen.setEnabled(true);
btnPalettenBestaetigen.setClickable(true);
btnPalettenBestaetigen.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
// do stuff
} catch (Exception e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
}
});
Here is my layout with the button visible:
Layout of my ListActivity
Why isn`t the Button visible when i launch the app?
I am glad for any help!
Greetings
Morris F.
SirGrey was right in the end.
That must be a problem with your code... But i can't see the issue, if the activity shows nothing, must be something with with the inflater... – SirGery
The Problem was the Inflater so i did the following changes to my code:
I deleted android:entries="#layout/paletten_item" from the XML of my MainActivity
The MainActivity now extends Activity and no more ListActivity
I setContentView() in my onCreate() method of my MainActivity
I get the ListView by doing listViewPaletten = (ListView)findViewById(R.id.listViewPaletten);
and I dont use the Infalter anymore.
Thanks a lot for your Help!
If you want to scroll your ListView meanwhile the button stays in same position, try to use FloatingActionButton, it must solve your issue
<ListView
android:id="#+id/listViewPaletten"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:entries="#layout/paletten_item"
android:minHeight="?android:attr/listPreferredItemHeight" >
</ListView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fActionButton"
android:layout_width="180dp"
android:layout_height="180dp"
tools:ignore="MissingConstraints,VectorDrawableCompat"/>
Then try this, swap the activity that makes reference, cause this is from my project
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activities.MainActivities.CartActivity">
<ListView
android:id="#+id/listViewPaletten"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp"
android:layout_above="#+id/buttonPalettenBetaetigen">
</ListView>
<Button
android:id="#+id/buttonPalettenBetaetigen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:text="Bestätigen" />

How to auto scroll downListView control when update new item- android studio

I have listview for my chat page....whenever i type new message in listview it not automatically scrolled down at botton.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15sp"
android:background="#drawable/chat_page"
tools:context=".Chatbox">
<Button
android:layout_width="40dp"
android:layout_height="40dp"
android:clickable="true"
android:id="#+id/sendbutton"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#drawable/send"
/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/sendbutton"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
<EditText
android:id="#+id/typemessage"
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Type a message..." />
</android.support.design.widget.TextInputLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_above="#id/sendbutton"
android:dividerHeight="5dp"
android:padding="10dp"
android:divider="#android:color/transparent"
android:id="#+id/listmessages"
android:layout_marginBottom="16dp"/>
</RelativeLayout>
When I add new text in listview then it should go to bottom of the page to see new messsage
You can try this out. But i suggest you to use to recyclerview instead of listview for Chat module.
private void scrollToBottom() {
listView.post(new Runnable() {
#Override
public void run() {
listView.setSelection(adapter.getCount() - 1);
}
});
}

How to fill page with overlay

I have a TRANSPARENT overlay in my android app that when user click on it,it fade but it can't fill all activity like below image
MainActivity :
<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"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="This is Original View" />
</RelativeLayout>
OverlayActivity :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/over_lay_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#50220000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="This is Overlay View" />
</RelativeLayout>
Java :
public class MainActivity extends Activity {
private ImageView mOverLayImage;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Dialog overlayInfo = new Dialog(MainActivity.this);
overlayInfo.requestWindowFeature(Window.FEATURE_NO_TITLE);
overlayInfo.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
overlayInfo.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
overlayInfo.setContentView(R.layout.overlay_view);
overlayInfo.show();
mOverLayImage = (ImageView) overlayInfo.findViewById(R.id.over_lay_image);
mOverLayImage.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
overlayInfo.cancel();
}
});
}
}
Use FrameLayout. Each item added to FrameLayout is on top of the previous one, like in this example the second TextView is on top of the frist one, but since it is not fully opaque, you can see them both!
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="Blablabla"
android:background="#FFFFFFFF"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#50220000"
android:textColor="#FFFFFF"
android:text="I am on top"
android:gravity="center"
/>
</FrameLayout>
Now all you need to do is show/hide the overlayed items and you are good to go.
Delete your overlay activity, and inside your main activity apply this code :
<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"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="This is Original View" />
<!-- This is your overlay -->
<RelativeLayout android:id="#+id/over_lay_page"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/over_lay_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#50220000"
android:onClick="clickedOverlay" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="This is Overlay View" />
</RelativeLayout>
</RelativeLayout>
Note that I added a line on your ImageView which runs a function when clicked, now on your java file add this function:
//The onClick on xml requires a function of signature void(View) which is the clicked view (in this case the ImageView)
public void clickedOverlay(View view)
{
//ImageView is clicked
RelativeLayout rlLayout = (RelativeLayout) findViewById(R.id.over_lay_page);
rlLayout.setVisibility(View.GONE);
}
This will make the RelativeLayout that contains the overlay views (including the ImageView which is clicked) to not only be invisible but not to interfere with anything. It also ignores input to it.
In case I misunderstood anything about your question feel free to correct me (I'm not sure I understood that completely).
Also if you want it to fade in or out or something like that you can do it with an AlphaAnimation.

Input type=number is not working

First of all , this is the problem on nexus 5 with default input method.
The problem is , if I use v4 fragment tab host with the edit-text (input type = number), when I type the number , then it will switch to alphabetical keypad, and nothing is input in the edit-text.
I am sure this is the problem with v4 fragment tab host as I tried tabhost it works, I use only activity instead of any tab host, it works. When input type = "text" , and switch to num pad , it works. I can capture onKeyDown event , too .
The only fail case is input type= number and the edit text is inside the v4 fragment tabhost
the layout of the tab fragment
<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" >
<EditText
android:id="#+id/edit_ratio"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:digits="0123456789."
android:inputType="number"
android:maxLength="4"
android:padding="5dp"
android:textSize="16sp" />
</RelativeLayout>
the layout of tab
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/tabBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="gone" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</LinearLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="#+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
java of the main activity
public class Main extends ActionBarActivity {
public static FragmentTabHost tabHost;
public static LinearLayout tabBar;
private String[] tags = { "home", "form", "calculator", "phone", "partner", "about_us", "settings" };
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
tabBar = (LinearLayout) findViewById(R.id.tabBar);
tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
tabHost.addTab(
tabHost.newTabSpec(tags[0]).setIndicator(""),
HomeFragment.class, null);
}
}
Also, I only found it happen when using input method named "Simplified cangjie keyboard" with nexus 5 . So I wonder how to fix it . Really Thanks a lot.

After take a picture and save it, sometimes the program crashes, doesn't return to the activity

I'm calling the function dispatchTakePictureIntent to take a picture. But after I take the picture and save it, the application doesn't returns correctly to the actual activity, the application crashes.
When my button is pressed I call
dispatchTakePictureIntent(1);
then:
public void dispatchTakePictureIntent(int actionCode) {
try {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = createImageFile();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(takePictureIntent, actionCode);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, actionCode);*/
}
public File createImageFile() throws IOException {
// Create an image file name
final String nomeForm = "teste";
String imageFileName = nomeForm +".jpeg";
File path = getExternalFilesDir(Environment.DIRECTORY_DCIM);
File image = new File(path,imageFileName );
// String getAbsolutePath = image.getAbsolutePath();
Toast.makeText(this, "Image saved to:\n" + image, Toast.LENGTH_LONG).show();
return image;
}
my logcat error report:
java.lang.RuntimeException: Unable to stop activity {com.example.sform/com.example.sform.mainRisco}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sform/com.example.sform.risco1}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.CompoundButton$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/0x1. Make sure other views do not use the same id.
Here all my layouts:
Tab Host Layout:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layout_riscos">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
The Tab1:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/risco1"
>
<RelativeLayout
android:id="#+id/geral_risco1"
android:layout_width="match_parent"
android:layout_height="739dp"
android:orientation="vertical"
android:screenOrientation="nosensor" >
<Button
android:id="#+id/pelicula_risco1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:layout_marginTop="36dp"
android:text="Take a Picture ;)"
android:textSize="30dp" />
<ImageView
android:id="#+id/imageView_risco1"
android:layout_width="9000dp"
android:layout_height="500dp"
android:layout_alignLeft="#+id/pelicula"
android:layout_marginTop="100dp"
android:layout_alignParentTop="true" >
</ImageView>
<RelativeLayout
android:id="#+id/riscoQ1_risco1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
</RelativeLayout>
</RelativeLayout>
</ScrollView>
The Tab2:
<TextView android:text="risco 2"
android:padding="15dip"
android:textSize="18dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/text_risco2"/>
</RelativeLayout>
The Tab3:
<TextView android:text="risco 3"
android:padding="15dip"
android:textSize="18dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/text_risco3"/>
</RelativeLayout>
The Tab4:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/geral_risco4">
<TextView android:text="risco 4"
android:padding="15dip"
android:textSize="18dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/text_risco4"/>
</RelativeLayout>
The Tab5:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/geral_risco5" >
<TextView android:text="risco 5"
android:padding="15dip"
android:textSize="18dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/text_risco5"/>
</RelativeLayout>
Main Activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:screenOrientation="nosensor"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
>
</RelativeLayout>
Another screen:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:screenOrientation="nosensor"
android:id="#+id/scroll_tela_form"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/info2"
>
<EditText
android:id="#+id/dataAnalise"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_below="#+id/textView3"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:layout_toLeftOf="#+id/getDate"
android:ems="10" />
<TextView
android:id="#+id/horaAnaliseFixo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/horaAnalise"
android:layout_below="#+id/dataAnalise"
android:layout_marginTop="8dp"
android:text="Hora de Inicio da Análise"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/nomeForm"
android:layout_marginTop="40dp"
android:text="Data da Análise"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/nomeForm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="35dp"
android:layout_toLeftOf="#+id/getDate"
android:layout_toRightOf="#+id/textView3"
android:text="NomeForm"
android:textSize="34dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/horaAnalise"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/horaAnaliseFixo"
android:layout_toLeftOf="#+id/getDate"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/getDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/horaAnaliseFixo"
android:layout_alignParentRight="true"
android:layout_marginRight="41dp"
android:text="Get Date" />
<Button
android:id="#+id/getTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/getDate"
android:layout_alignParentBottom="true"
android:text="Get Time" />
</RelativeLayout>
</ScrollView>
Another reason for this issue can be two (or more) layout files for the same layout stored under layout, layout-land, layout-w600dp etc. If these layouts have views of different types sharing same id, then you can get this exception two. To reproduce the exception you need to call function dispatchTakePictureIntent(), then rotate your device, then take picture and return back. Does it help?
You have used same id for two different views.
Check your layout XML & use different ids for different views.
It says that you are using the same id for different views and that the id is 0x1. That looks suspiciously like
a) somewhere a view id is expected, something else is given or
b) the R.java is generated incorrectly. Please check if theres an id of 1 in there somewhere.
Did you check the value of
#android:id/tabs
#android:id/tabcontent
?

Categories