My layouts and views' ids, eclipse can not recognize them and underscore them with red line.
I built all the projects and cleaned them as well, but the problem still exists. Please provide any suggestions.
UPDATE:
The updated problem is, the R class is highlighted with red
JavaCode:
setContentView(R.layout.mplmenu_activity);
mMainMenuListView = (ListView) findViewById(R.id.ListView_Menu);
String [] items = {
getResources().getString(R.string.menuItem_AddNewLocation),
getResources().getString(R.string.menuItem_MySavedLocation),
getResources().getString(R.string.menuItem_GPSReadings),
getResources().getString(R.string.menuItem_OpenCameraSurface)
};
ArrayAdapter<String> adapt =new ArrayAdapter<String>(this,
R.layout.mainMenuItems, items);
mplmenu_activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/mplMenuActivityBackGroundColor" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal">
<TextView
android:id="#+id/TextView01"
android:layout_height="wrap_content"
android:text="#string/menu"
android:textSize="#dimen/mainMenuTextSize"
android:layout_marginLeft="18dp"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="10"
android:layout_width="wrap_content"
android:shadowColor="#android:color/white"
android:textColor="#color/mainMenuTextColor">
</TextView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout02"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_gravity="center">
<ListView
android:layout_height="wrap_content"
android:id="#+id/ListView_Menu"
android:layout_width="wrap_content"
android:divider="#drawable/dividerline"
android:layout_alignParentTop="true">
</ListView>
</RelativeLayout>
</LinearLayout>
Check that the generated R.java file actually exists. You may have errors in some of your XML resource files that prevent the Android build tool aapt from generating the R.java file. In my experience, that is typically why resource IDs are not found.
To fix this, you will have to fix the XML errors.
If you have something like import your_package_name.R in your Activity class, remove it, and clean the project, then build it again.
Make sure that you are identifying them in your xml with the +id and not just id.
Like this:
android:id="+id/btn1"
not this:
android:id="id/btn1"
Related
I am a new user in Android dev. Actually I have one problem that I can't solve for much time.
I have a layout with Scroll View, there are ImageView and TextView in this ScrollView. You can see it in my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity ="center"
android:fillViewport="true"
android:id="#+id/scrollView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:padding="10dp"/>
<TextView
android:id="#+id/textInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I take the data from JSON and using this layout for input it in.
There are images that have different forms.
So, please, help me with it. What I must to do with layout markup and what scaleType I must to use.
Thanks in advance.
P.S. Sorry for my English)
It would be helpful if you posted the code that takes the data from a json too.
For picking the right scaletype, this might help.
Hello) I have already solve my problem. I need only to add this things
android:scaleType="fitCenter"
android:adjustViewBounds="true"
I just forgot what adjustViewBounds do)
I'm trying to use the AndroidSlidingUpPanel library (in Eclipse) and I have this error:
04-19 20:09:48.413: E/AndroidRuntime(13760): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mendozatourapp/com.mendozatourapp.activitys.MapsActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.sothree.slidinguppanel.library.SlidingUpPanelLayout
This is my layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DemoActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/lib/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp"
sothree:paralaxOffset="100dp"
sothree:dragView="#+id/name">
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
I downloaded the entire project and imported "main" as library. Then I add this library to my project's java build path. I have the feeling that is a java build path problem. Any idea?
Thank you so much for reading me and take your time to do it.
I just got it working in Eclipse.
The important part is to get your library project created correctly and then link it up to your main project.
For the library project, I created a project.properties file, and also added the jar files for the RecyclerView library, the support v4 library, and nineoldandroids.
I also created a .classpath file in order to make it automatically put the java folder in the build path.
I uploaded the library project that I got working to github: https://github.com/dmnugent80/SlidingUpPanel-for-Eclipse/tree/master
Then, import the library project into your workspace:
Set it up as a dependency of the main project:
So, you end up with something like this:
Then, using this test xml (your xml threw an error about needing a minimum of two children):
<?xml version="1.0" encoding="utf-8"?>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="#+id/dragView"
sothree:umanoOverlay="true"
sothree:umanoScrollableView="#+id/list">
<!-- MAIN CONTENT -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="Main Content"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:textSize="16sp" />
</FrameLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
android:id="#+id/dragView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal">
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="10dp"/>
<Button
android:id="#+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:gravity="center_vertical|right"
android:paddingRight="10dp"
android:paddingLeft="10dp"/>
</LinearLayout>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
It works!
i would try to change the system recent app layout in a custom rom. Actually, in android stock, we have a simple vertical scrollable column with recent apps.. I would change it and make a gridview like LG --> http://www.androidcentral.com/sites/androidcentral.com/files/styles/large_wm_brw/public/article_images/2014/07/task-switchers.jpg?itok=DQwWAMpQ it's not so easy and i need help.. i have some question;
1) Change the xml only is enought?
2) Have i to change the adapter too in java or something else in java code?
The xml is this one:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.recent.RecentsPanelView
android:id="#id/recents_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:foreground="#drawable/bg_protect"
systemui:recentItemLayout="#layout/status_bar_recent_item"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="#id/recents_bg_protect"
android:background="#drawable/status_bar_recents_background"
android:fitsSystemWindows="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<com.android.systemui.recent.RecentsVerticalScrollView
android:layout_gravity="top|left|center"
android:id="#id/recents_container"
android:scrollbars="none"
android:fadingEdge="vertical"
android:fadingEdgeLength="#dimen/status_bar_recents_scroll_fading_edge_length"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:divider="#null"
android:layout_marginEnd="0.0dip">
<LinearLayout
android:id="#id/recents_linear_layout"
android:fitsSystemWindows="true"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</com.android.systemui.recent.RecentsVerticalScrollView>
<ImageView
android:layout_gravity="bottom|left|center"
android:id="#id/recents_clear"
android:clickable="true"
android:layout_width="50.0dip"
android:layout_height="50.0dip"
android:src="#drawable/ic_notify_clear"
android:scaleType="center" />
</FrameLayout>
<include android:id="#id/recents_no_apps" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" layout="#layout/status_bar_no_recent_apps" />
</com.android.systemui.recent.RecentsPanelView>
The class RecentsPanelView extends a FrameLayout.. i tried simple change and extends a gridview but without any changes.. i think it was too much easy just change this point.. However, actually with this xml i can display in horizontal the recent apps but only in one row.. Any idea? Maybe adding a gridview in this layout?
I hope that you can help me with this. I have a XML with a checkBox control and I want change its to checked by code.
When Android Studio compiles, the code has an error in "cb.setChecked(true)". FATAL EXCEPTION: main
java.lang.NullPointerException
CheckBox cb = (CheckBox) findViewById(R.id.checkBox);
cb.setChecked(true);
XML file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff8989"
android:id="#+id/backColor"
android:divider="#drawable/ic_launcher"
android:longClickable="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="20dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/checkBox"
android:layout_gravity="left|top"
android:checked="false"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="..."
android:id="#+id/txt_tarea"
android:paddingLeft="10dp"
android:textSize="15sp"/>
</LinearLayout>
</LinearLayout>
Thanks.
Please check the id that you provide to findViewById. Is it present in your layout.xml. ALso have to inflated the view using that layout file before calling this. Please verify these points and I think your problem will be solved.
I have been working on an Android Application project recently, and I've notice that some of my code IDs within a XML file will not register within the R file, and I have not been able to access the IDs within my classes. The code within the XML file will look like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_height="250dp"
android:layout_gravity="center"
android:src="#drawable/icon"
android:id="#+id/ivReturnedPic"
android:layout_width="250dp"></ImageView>
<ImageButton android:layout_height="wrap_content"
android:src="#drawable/icon"
android:id="#+id/ibTakePic"
android:layout_width="125dp"
android:layout_gravity="center"></ImageButton>
<Button android:text="Set Wallpaper"
android:id="#+id/bSetWall"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_gravity="center"></Button>
</LinearLayout>
None of theses IDs will register within the resource file.
There's problem in your xml that's why R is not being generated automatically
Remove one of extra </LinearLayout>
you must be sure that the image "icon.png" or "icon.jpg" is under your res/drawable folder.
android:src="#drawable/icon"