Search Results

Search found 12035 results on 482 pages for 'android emulator'.

Page 4/482 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Android - Display HTML Formatted String

    - by Soren
    I need an example of how to display the strings that I have marked up with simple html into a TextView. I have found "Spanned fromHtml(String source)", but I don't know how to plug it into my java code. Here is my Java: package com.SorenWinslow.TriumphHistory; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class TriumphHistory extends ListActivity { String[] HistoryList; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayAdapter<String> adapter; HistoryList = getResources().getStringArray(R.array.history); adapter = new ArrayAdapter<String> (this,R.layout.historylistlayout,HistoryList); setListAdapter(adapter); } } Here is a sample of history: <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="history"> <item><b>1883</b><br/>Some stuff happened</item> <item><b>1884</b><br/>Some more stuff happened <i>before</i> the other stuff </item> <resources> Here is my historylistlayout.xml: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:textColor="#ffffff" android:background="#000050" android:layout_marginTop="5px" android:minHeight="?android:attr/listPreferredItemHeight" android:padding="3px" android:textSize="8pt" android:layout_gravity="top|left"/> And here is my main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:textColor="#ffffff" android:background="#000080" android:isScrollContainer="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:scrollbarStyle="insideOverlay"> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:dividerHeight="1px"/> </LinearLayout>

    Read the article

  • Why my button can trigger the UI to scroll and my TimerTask inside the activity can't?

    - by Spidey
    Long Story Short: a method of my activity updates and scrolls the ListView through an ArrayAdapter like it should, but a method of an internal TimerTask for polling messages (which are displayed in the ListView) updates the ListView, but don't scroll it. Why? Long Story: I have a chat activity with this layout: <?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="fill_parent" android:background="#fff" > <ListView android:id="@+id/messageList" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stackFromBottom="true" android:transcriptMode="alwaysScroll" android:layout_weight="1" android:fadeScrollbars="true" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" > <EditText android:id="@+id/message" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:id="@+id/button_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" android:onClick="sendMessage" /> </LinearLayout> </LinearLayout> The internal listView (with id messageList) is populated by an ArrayAdapter which inflates the XML below and replaces strings in it. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="false" android:background="#fff" android:paddingLeft="2dp" android:paddingRight="2dp" > <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" android:textColor="#00F" android:typeface="monospace" android:text="2010-10-12 12:12:03" android:gravity="left" /> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/sender" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="16sp" android:textColor="#f84" android:text="spidey" android:gravity="right" android:textStyle="bold" /> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/body" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="14sp" android:padding="1dp" android:gravity="left" android:layout_below="@id/date" android:text="Mensagem muito legal 123 quatro cinco seis." android:textColor="#000" /> </RelativeLayout> The problem is: in the main layout, I have a EditText for the chat message, and a Button to send the message. I have declared the adapter in the activity scope: public class ChatManager extends Activity{ private EditText et; private ListView lv; private Timestamp lastDate = null; private long campaignId; private ChatAdapter ca; private List<ChatMessage> vetMsg = new ArrayList<ChatMessage>(); private Timer chatPollingTimer; private static final int CHAT_POLLING_PERIOD = 10000; ... } So, inside sendMessage(View v), the notifyDataSetChanged() scrolls the ListView acordingly, so I can see the latest chat messages automatically: public void sendMessage(View v) { String msg = et.getText().toString(); if(msg.length() == 0){ return; } et.setText(""); String xml = ServerCom.sendAndGetChatMessages(campaignId, lastDate, msg); Vector<ChatMessage> vetNew = Chat.parse(new InputSource(new StringReader(xml))); //Pegando a última data if(!vetNew.isEmpty()){ lastDate = vetNew.lastElement().getDateSent(); //Atualizando a tela vetMsg.addAll(vetNew); ca.notifyDataSetChanged(); } } But inside my TimerTask, I can't. The ListView IS UPDATED, but it just don't scroll automatically. What am I doing wrong? private class chatPollingTask extends TimerTask { @Override public void run() { String xml; if(lastDate != null){ //Chama o Updater xml = ServerCom.getChatMessages(campaignId, lastDate); }else{ //Chama o init denovo xml = ServerCom.getChatMessages(campaignId); } Vector<ChatMessage> vetNew = Chat.parse(new InputSource(new StringReader(xml))); if(!(vetNew.isEmpty())){ //TODO: descobrir porque o chat não está rolando quando chegam novas mensagens //Descobrir também como forçar o rolamento, enquanto o bug não for corrigido. Log.d("CHAT", "New message(s) acquired!"); lastDate = vetNew.lastElement().getDateSent(); vetMsg.addAll(vetNew); ca.notifyDataSetChanged(); } } } How can I force the scroll to the bottom? I've tried using scrollTo using lv.getBottom()-lv.getHeight(), but didn't work. Is this a bug in the Android SDK? Sorry for the MASSIVE amount of code, but I guess this way the question gets pretty clear.

    Read the article

  • 2 fundamental questions for the Androgurus ...Can someone guide me

    - by Saul Carpenter
    I have'nt plunged into Android Development as yet though Java Classes C++ all that is not new to me. Here are the questions folks. Appreciated any help on these : - If I need to develop test and deploy Android Apps do I NEED AN ANDROID Hardware device or is there a software Android Simulator like VMWARE or Virtual PC , where I can emulate the results.If there is such can you point me more info I have a Netbook ( the Chinese Ipad Clone ) running Android that has only Wi-Fi for the present. Is it possible to add the following features via the spare USB Port --- a USB Based 56K Modem : Are there Android platform H/W Drivers. --- a USB based RJ45 ( Ethernet LAN LandLine connection ) Adapter :Are there Android platform H/W Drivers. Please advise Thanks Saul

    Read the article

  • Android : create RelativeLayout in Onclick Button?(Get Crash)

    - by A.A
    I have an Xml that add LinearLayout and RelativeLayout in ScrollView by programmatically.When i add Text with OnclickButton for first time show me message but for 2nd time get me crash : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ScrollView android:id="@+id/scrollID" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" > </ScrollView> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingLeft="5dp" android:paddingRight="5dp" android:weightSum="1" > <EditText android:id="@+id/txtInpuConversation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.5" android:hint="Text" > <requestFocus /> </EditText> <Button android:id="@+id/btnSend" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="Click" /> </LinearLayout> </LinearLayout> My code : public class MainActivity extends Activity { String Medtconversation; EditText edtconversation; TextView txtviewUser; LinearLayout rilative; RelativeLayout relativeLayout; LinearLayout firstLinearLayout; ScrollView sclView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edtconversation = (EditText) findViewById(R.id.txtInpuConversation); sclView = (ScrollView) findViewById(R.id.scrollID); Button btn = (Button) findViewById(R.id.btnSend); final Context context = this; btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Medtconversation = edtconversation.getText().toString(); txtviewUser = new TextView(MainActivity.this); txtviewUser.setText(Medtconversation); relativeLayout = new RelativeLayout(context); firstLinearLayout= new LinearLayout(context); LayoutParams LLParamsT = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); relativeLayout.setLayoutParams(LLParamsT); relativeLayout.addView(txtviewUser, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); firstLinearLayout.setOrientation(LinearLayout.VERTICAL); LayoutParams LLParams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); firstLinearLayout.setLayoutParams(LLParams); firstLinearLayout.addView(relativeLayout); Crash here now======>sclView.addView(firstLinearLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); edtconversation.setText(""); } }); } } I need that when i click on Button and send message for 2nd time create a new RelativeLayout in LinearLayout for show.(In scrollView) Error : AndroidRuntime MainActivity$1.onClick(MainActivity.java:54)

    Read the article

  • fitting buttons for multiple screens

    - by user3360327
    I want to develop my own keyboard and when I put first line button as you see the buttons are not fitting with any screens size. these are my questions: 1) how can I fit them? 2) is <TableLayout> is correct view layout? if it's not, which one is correct? this is XML code: <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/btnQ" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strQ" /> <Button android:id="@+id/btnW" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strW" /> <Button android:id="@+id/btnE" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strE" /> <Button android:id="@+id/btnR" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strR" /> <Button android:id="@+id/btnT" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strT" /> <Button android:id="@+id/btnY" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strY" /> <Button android:id="@+id/btnU" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strU" /> <Button android:id="@+id/btnI" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strI" /> <Button android:id="@+id/btnO" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strO" /> <Button android:id="@+id/btnP" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/strP" /> </TableLayout>

    Read the article

  • How can I force my checkbox's text to not wrap?

    - by B. Clay Shannon
    This is what my LinearLayout (horizontal) row looks like: I want the text of the checkbox to be on one line; The buttons don't have to be that wide - they'll still have plenty of space with the checkbox text lengthened a bit. What in my XML: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:id="@+id/ckbxAllow_New_Items" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" android:checked="true" android:text="@string/checkbox_Allow_New_Items" /> <Button android:id="@+id/btnOK" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_OK" /> <Button android:id="@+id/btnCancel" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/button_Cancel" /> </LinearLayout> ...needs to change in order to force my checkbox text not to wrap? UPDATE Following Der Golem's suggestion by adding this: android:lines="1" ...and also changing layout_weight for the checkbox from 1 to 2 (set to 1 for the buttons) gave me what I wanted:

    Read the article

  • How to add controls to a Tab Layout in Android?

    - by chobo2
    Hi I am following this tutorial http://developer.android.com/intl/de/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually like to add you know some controls to these tabs like textboxes(text edit). How do I do this? I go to my mail.xml using eclipse as my ide and go to layout view and I now get a NullPointerException so I can't even drag stuff onto the layout anymore. Thanks Edit This is what I have <?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"> <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 android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/textview1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is a tab" /> <EditText android:text="" android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:password="true"></EditText> </LinearLayout> <TextView android:id="@+id/textview2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is another tab" /> <TextView android:id="@+id/textview3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is a third tab" /> </FrameLayout> </LinearLayout> </TabHost>

    Read the article

  • Scale background image to wrap content of layout

    - by bjg222
    I have a layout that contains some text fields and has a background image that's displayed at the top of my activity. I'd like the background image to scale to wrap the content (don't care about aspect ratio). However, the image is larger than content, so the layout instead wraps the background image. Here's my original code: <RelativeLayout android:layout_width="fill_parent" android:id="@+id/HeaderList" android:layout_gravity="top" android:layout_height="wrap_content" android:background="@drawable/header"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/NameText" android:text="Jhn Doe" android:textColor="#FFFFFF" android:textSize="30sp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:paddingLeft="4dp" android:paddingTop="4dp" /> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:textColor="#FFFFFF" android:layout_alignParentLeft="true" android:id="@+id/HoursText" android:text="170 hours" android:textSize="23sp" android:layout_below="@+id/NameText" android:paddingLeft="4dp" /> </RelativeLayout> After searching through some other questions, I found these two: How to wrap content views rather than background drawable? Scale a Drawable or background image? Based on this, I created a FrameLayout w/ an ImageView showing the background. Unfortunately, I still can't get it to work. I want the height of the background image to shrink/expand w/ the size of the text views, but with the FrameLayout, the ImageView fits to the size of it's parent, and I can't find a way to make the parent fit to the size the text view layout. Here's my updated code: <FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <ImageView android:src="@drawable/header" android:layout_width="fill_parent" android:scaleType="fitXY" android:layout_height="fill_parent" /> <RelativeLayout android:layout_width="fill_parent" android:id="@+id/HeaderList" android:layout_gravity="top" android:layout_height="wrap_content" > <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/NameText" android:text="John Doe" android:textColor="#FFFFFF" android:textSize="30sp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:paddingLeft="4dp" android:paddingTop="4dp" /> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:textColor="#FFFFFF" android:layout_alignParentLeft="true" android:id="@+id/HoursText" android:text="170 hours" android:textSize="23sp" android:layout_below="@+id/NameText" android:paddingLeft="4dp" /> </RelativeLayout> </FrameLayout> Does anybody have any suggestions for how best to make an image scale to the size of the contents of some layout? I'm not concerned with the aspect ratio of the image, as it won't matter, I just want it to fill the background. Thanks!

    Read the article

  • Linear Layout over relative layout

    - by Sai
    I have a relative layout for Camera preview with some overlay features. The layout file looks like the one in shown below: <?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" > <android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/preview" android:layout_width="fill_parent" android:layout_height="fill_parent" > </android.view.SurfaceView> </RelativeLayout> I integrated some menu options from the android bluetooth chat example. The menu options work fine but if I click on one of the options, the app just froze. It opens a debug perspective but I am not able to understand them. The app does not seem to crash but it just froze. The layout that I am using for the menu options is: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/title_paired_devices" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/title_paired_devices" android:visibility="gone" android:textColor="#fff" android:paddingLeft="5dp" /> <ListView android:id="@+id/paired_devices" android:layout_width="match_parent" android:layout_height="wrap_content" android:stackFromBottom="true" android:layout_weight="1" /> <TextView android:id="@+id/title_new_devices" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/title_other_devices" android:visibility="gone" android:textColor="#fff" android:paddingLeft="5dp" /> <ListView android:id="@+id/new_devices" android:layout_width="match_parent" android:layout_height="wrap_content" android:stackFromBottom="true" android:layout_weight="2" /> Can I attribute this to the fact that I am trying to overlay Linear layout over relative layout? Any suggestions to display the list of bluetooth devices over camera preview would be greatly appreciated

    Read the article

  • NfcAdapter.getDefaultAdapter(this) returns null in emulator

    - by DixieFlatline
    I am trying to test ForegroundDispatch (http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundDispatch.html) in emulator API 10 (Android 2.3.3). When i call NfcAdapter.getDefaultAdapter(this), i get null. Why is this so? Code: public class ForegroundDispatch extends Activity { private NfcAdapter mAdapter; private PendingIntent mPendingIntent; private IntentFilter[] mFilters; private String[][] mTechLists; private TextView mText; private int mCount = 0; @Override public void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.foreground_dispatch); mText = (TextView) findViewById(R.id.text); mText.setText("Scan a tag"); mAdapter = NfcAdapter.getDefaultAdapter(this); // Create a generic PendingIntent that will be deliver to this activity. The NFC stack // will fill in the intent with the details of the discovered tag before delivering to // this activity. mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter for all MIME based dispatches IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] { ndef, }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; } @Override public void onResume() { super.onResume(); mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists); //CRASHES HERE BECAUSE mAdapter IS NULL } @Override public void onNewIntent(Intent intent) { Log.i("Foreground dispatch", "Discovered tag with intent: " + intent); mText.setText("Discovered tag " + ++mCount + " with intent: " + intent); } @Override public void onPause() { super.onPause(); mAdapter.disableForegroundDispatch(this); } } My manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.neka.znacka" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.NFC"></uses-permission> <uses-feature android:name="android.hardware.nfc" android:required="true" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Uvodna" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="Simulator"> </activity> </application> Any ideas?

    Read the article

  • Android ViewPager Displaying TextView in Layout

    - by Ammonious
    I'm having a problem getting my viewpager to work correctly. Currently the bottom part of my layout will page across but the remaining part will not Here's my code that I have in my PageAdapter public class MyPageAdapter extends PagerAdapter { public int getCount() { return 31; } public Object instantiateItem(View collection, int position) { LayoutInflater inflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); int resId = 0; switch (position) { case 0: resId = R.layout.main_menu; break; case 1: resId = R.layout.article1; break; case 2: resId = R.layout.article2; break; .... .... View view = inflater.inflate(resId, null); ((ViewPager) collection).addView(view, 0); return view; This is what I have for my XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/background" android:clickable="true" android:id="@+id/layout13" android:weightSum="0"> <TextView android:id="@+id/textView01" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:padding="12dp" android:text="@string/article13" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#000000" /> <TextView android:id="@+id/textView02" android:layout_width="match_parent" android:layout_height="302dp" android:gravity="center_vertical|center_horizontal" android:text="@string/body13" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#000000" /> <android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@id/viewPager" > </android.support.v4.view.ViewPager> </LinearLayout> I've tried Moving the around in my XML layout to right underneath my LinearLayout and i get the full screen but all my text disappears. It's probably something simple i'm missing but any help on this would be greatly appreciated!

    Read the article

  • Problems with calendar application on Android 2.1

    - by Rick
    Hi, I have compiled the android 2.1 source code and I can start the emulator. But I can't launch calendar application. Every time I tried to lauch the calendar application, it crashed. The log is as following: // CRASH: com.android.calendar (pid 272) // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException // Build Label: android:generic/generic/generic/:2.1-update1/ERE27/eng.root.20100317.113135:eng/test-keys // Build Changelist: -1 // Build Time: 1268798948 // ID: // Tag: AndroidRuntime // java.lang.NullPointerException: // at com.android.providers.calendar.CalendarSyncAdapter.onAccountsChanged(CalendarSyncAdapter.java:1400) // at android.content.AbstractSyncableContentProvider$1.onAccountsUpdated(AbstractSyncableContentProvider.java:189) // at android.accounts.AccountManager$10.run(AccountManager.java:826) // at android.os.Handler.handleCallback(Handler.java:587) // at android.os.Handler.dispatchMessage(Handler.java:92) // at android.os.Looper.loop(Looper.java:123) // at android.app.ActivityThread.main(ActivityThread.java:4363) // at java.lang.reflect.Method.invokeNative(Method.java:-2) // at java.lang.reflect.Method.invoke(Method.java:521) // at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) // at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) // at dalvik.system.NativeStart.main(NativeStart.java:-2) has anyone met this problem, or any suggestions on how to fix it? Thanks very much!! Rick

    Read the article

  • Start Learning Android

    - by Shrewd Demon
    hi, i am a beginner with Android. I want to learn more about this new revolution. Kindly help me with links that will help me learn creating applications for Android. Please share if you have some simple source-code sites with you. Also show me a forum having high activity with Android users... thank you !

    Read the article

  • Android ndk-build command does nothing

    - by James
    I have a similar question to that posted here: Android NDK: why ndk-build doesn't generate .so file and a new libs folder in Eclipse? ...though I am running Windows 7, not Mac os. Essentially the ndk-build command is run, gives no error but doesn't create an .so file (also, since I'm on windows this should create a .dll and not an .so?). I tried running the command from the root, jni, src folders etc. but got the same result; cmd just returns to the prompter after a few seconds. I ran it again from the jni folder with NDK_LOG=1 parameter to see what was happening. Here is a portion of the transcript of the log results after running ndk-build in the jni folder (after it successfully identified the platform, etc.)... Android NDK: Looking for jni/Android.mk in /workspace/NdkFooActivity/jni Android NDK: Looking for jni/Android.mk in /workspace/NdkFooActivity Android NDK: Found it ! Android NDK: Found project path: /workspace/NdkFooActivity Android NDK: Ouput path: /workspace/NdkFooActivity/obj Android NDK: Parsing /cygdrive/c/android-ndk-r8/build/core/default-application.mk Android NDK: Found APP_PLATFORM=android-15 in /workspace/NdkFooActivity/project.properties Android NDK: Application local targets unknown platform 'android-15' Android NDK: Switching to android-14 Android NDK: Using build script /workspace/NdkFooActivity/jni/Android.mk Android NDK: Application 'local' is not debuggable Android NDK: Selecting release optimization mode (app is not debuggable) Android NDK: Adding import directory: /cygdrive/c/android-ndk-r8/sources Android NDK: Building application 'local' for ABI 'armeabi' Android NDK: Using target toolchain 'arm-linux-androideabi-4.4.3' for 'armeabi' ABI Android NDK: Looking for imported module with tag 'cxx-stl/system' Android NDK: Probing /cygdrive/c/android-ndk-r8/sources/cxx-stl/system/Android.mk Android NDK: Found in /cygdrive/c/android-ndk-r8/sources/cxx-stl/system Android NDK: Cygwin dependency file conversion script: ...after which point it just runs the script mentioned in the last line, then terminates. Any ideas? Thanks!

    Read the article

  • Android Layout: Display as much ImageViews as possible without scrolling

    - by Toni4780
    I am working on an app which should display several same size images on the screen. But it should only display only so much images as possible without offering scrolling. E.g. On a "big" tablet it could display 10x10 Imageviews (screen is large, so there is much space for pictures) On a "big" phone there might be enough space to display 6x6 ImageViews, so it should only display a 6x6 array of images. On a small phone there is propably only space for 4x4 ImageViews, so it should only display this. How can I make this in Android? I know about "layout-large", ... but if i make a special fixed xml-layout for a "large" device, it would not fit all devices correct. E.g. a Galaxy Nexus is a "normal" device and so is a Nexus One, but there would be at least be space for one or two more imageview rows on a Galaxy Nexus than on a Nexus One. So do I have to measure in code somehow how big the resolution is and display some TableRows accordingly? Or is there a special way how I can manage this?

    Read the article

  • Android: NullPointerException error in getting data in database

    - by Gil Viernes Marcelo
    This what happens in the system. 1. Admin login this is in other activity but i will not post it coz it has nothing to do with this (no problem) 2. Register user in system (using database no problem) 3. Click add user button (where existing user who register must display its name in ListView) Problem: When I click adduser to see if the system registered the user, it force close. CurrentUser.java package com.example.istronggyminstructor; import java.util.ArrayList; import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ListView; import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.List; import java.util.Random; import com.example.istronggyminstructor.registeredUserList.Users; import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; public class CurrentUsers extends Activity { private Button register; private Button adduser; EditText getusertext, getpass, getweight, textdisp; View popupview, popupview2; public static ArrayList<String> ArrayofName = new ArrayList<String>(); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_current_users); register = (Button) findViewById(R.id.regbut); adduser = (Button) findViewById(R.id.addbut); register.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { LayoutInflater inflator = (LayoutInflater) getBaseContext() .getSystemService(LAYOUT_INFLATER_SERVICE); popupview = inflator.inflate(R.layout.popup, null); final PopupWindow popupWindow = new PopupWindow(popupview, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); popupWindow.showAtLocation(popupview, Gravity.CENTER, 0, 0); popupWindow.setFocusable(true); popupWindow.update(); Button dismissbtn = (Button) popupview.findViewById(R.id.close); dismissbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { popupWindow.dismiss(); } }); popupWindow.showAsDropDown(register, 50, -30); } }); //Thread.setDefaultUncaughtExceptionHandler(new forceclose(this)); } public void registerUser(View v) { EditText username = (EditText) popupview.findViewById(R.id.usertext); EditText password = (EditText) popupview .findViewById(R.id.passwordtext); EditText weight = (EditText) popupview.findViewById(R.id.weight); String getUsername = username.getText().toString(); String getPassword = password.getText().toString(); String getWeight = weight.getText().toString(); dataHandler dbHandler = new dataHandler(this, null, null, 1); Users user = new Users(getUsername, getPassword, Integer.parseInt(getWeight)); dbHandler.addUsers(user); Toast.makeText(getApplicationContext(), "Registering...", Toast.LENGTH_SHORT).show(); } public void onClick_addUser(View v) { LayoutInflater inflator = (LayoutInflater) getBaseContext() .getSystemService(LAYOUT_INFLATER_SERVICE); popupview2 = inflator.inflate(R.layout.popup2, null); final PopupWindow popupWindow = new PopupWindow(popupview2, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); popupWindow.showAtLocation(popupview2, Gravity.CENTER, 0, -10); popupWindow.setFocusable(true); popupWindow.update(); Button dismissbtn = (Button) popupview2.findViewById(R.id.close2); dismissbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { popupWindow.dismiss(); } }); popupWindow.showAsDropDown(register, 50, -30); dataHandler dbHandler = new dataHandler(this, null, null, 1); dbHandler.getAllUsers(); ListView list = (ListView)findViewById(R.layout.popup2); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ArrayofName); list.setAdapter(adapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.current_users, menu); return true; } } registeredUserList.java package com.example.istronggyminstructor; public class registeredUserList { public static class Users { private static int _id; private static String _users; private static String _password; private static int _weight; private static String[] _workoutlists; private static int _score; public Users() { } public Users(String username, String password, int weight) { _users = username; _password = password; _weight = weight; } public int getId() { return _id; } public static void setId(int id) { _id = id; } public String getUsers() { return _users; } public static void setUsers(String users) { _users = users; } public String getPassword(){ return _password; } public void setPassword(String password){ _password = password; } public int getWeight(){ return _weight; } public static void setWeight(int weight){ _weight = weight; } public String[] getWorkoutLists(){ return _workoutlists; } public void setWorkoutLists(String[] workoutlists){ _workoutlists = workoutlists; } public int score(){ return _score; } public void score(int score){ _score = score; } } } dataHandler.java package com.example.istronggyminstructor; import java.util.ArrayList; import java.util.List; import com.example.istronggyminstructor.registeredUserList.Users; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; public class dataHandler extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "userInfo.db"; public static final String TABLE_USERINFO = "user"; public static final String COLUMN_ID = "_id"; public static final String COLUMN_USERNAME = "username"; public static final String COLUMN_PASSWORD = "password"; public static final String COLUMN_WEIGHT = "weight"; public dataHandler(Context context, String name, CursorFactory factory, int version) { super(context, DATABASE_NAME, factory, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String CREATE_USER_TABLE = "CREATE TABLE " + TABLE_USERINFO + " (" + COLUMN_ID + " INTEGER PRIMARY KEY, " + COLUMN_USERNAME + " TEXT," + COLUMN_PASSWORD + " TEXT, " + COLUMN_WEIGHT + " INTEGER " + ");"; db.execSQL(CREATE_USER_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_USERINFO); onCreate(db); } public void addUsers(Users user) { ContentValues values = new ContentValues(); values.put(COLUMN_USERNAME, user.getUsers()); values.put(COLUMN_PASSWORD, user.getPassword()); values.put(COLUMN_WEIGHT, user.getWeight()); SQLiteDatabase db = this.getWritableDatabase(); db.insert(TABLE_USERINFO, null, values); db.close(); } public Users findUsers(String username) { String query = "Select * FROM " + TABLE_USERINFO + " WHERE " + COLUMN_USERNAME + " = \"" + username + "\""; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(query, null); Users user = new Users(); if (cursor.moveToFirst()) { cursor.moveToFirst(); Users.setUsers(cursor.getString(1)); //Users.setWeight(Integer.parseInt(cursor.getString(3))); not yet needed cursor.close(); } else { user = null; } db.close(); return user; } public List<Users> getAllUsers(){ List<Users> user = new ArrayList(); String selectQuery = "SELECT * FROM " + TABLE_USERINFO; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Users users = new Users(); users.setUsers(cursor.getString(1)); String name = cursor.getString(1); CurrentUsers.ArrayofName.add(name); // Adding contact to list user.add(users); } while (cursor.moveToNext()); } // return user list return user; } public boolean deleteUsers(String username) { boolean result = false; String query = "Select * FROM " + TABLE_USERINFO + " WHERE " + COLUMN_USERNAME + " = \"" + username + "\""; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(query, null); Users user = new Users(); if (cursor.moveToFirst()) { Users.setId(Integer.parseInt(cursor.getString(0))); db.delete(TABLE_USERINFO, COLUMN_ID + " = ?", new String[] { String.valueOf(user.getId()) }); cursor.close(); result = true; } db.close(); return result; } } Logcat 08-20 03:23:23.293: E/AndroidRuntime(16363): FATAL EXCEPTION: main 08-20 03:23:23.293: E/AndroidRuntime(16363): java.lang.IllegalStateException: Could not execute method of the activity 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.view.View$1.onClick(View.java:3599) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.view.View.performClick(View.java:4204) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.view.View$PerformClick.run(View.java:17355) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.os.Handler.handleCallback(Handler.java:725) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.os.Handler.dispatchMessage(Handler.java:92) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.os.Looper.loop(Looper.java:137) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.app.ActivityThread.main(ActivityThread.java:5041) 08-20 03:23:23.293: E/AndroidRuntime(16363): at java.lang.reflect.Method.invokeNative(Native Method) 08-20 03:23:23.293: E/AndroidRuntime(16363): at java.lang.reflect.Method.invoke(Method.java:511) 08-20 03:23:23.293: E/AndroidRuntime(16363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 08-20 03:23:23.293: E/AndroidRuntime(16363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 08-20 03:23:23.293: E/AndroidRuntime(16363): at dalvik.system.NativeStart.main(Native Method) 08-20 03:23:23.293: E/AndroidRuntime(16363): Caused by: java.lang.reflect.InvocationTargetException 08-20 03:23:23.293: E/AndroidRuntime(16363): at java.lang.reflect.Method.invokeNative(Native Method) 08-20 03:23:23.293: E/AndroidRuntime(16363): at java.lang.reflect.Method.invoke(Method.java:511) 08-20 03:23:23.293: E/AndroidRuntime(16363): at android.view.View$1.onClick(View.java:3594) 08-20 03:23:23.293: E/AndroidRuntime(16363): ... 11 more 08-20 03:23:23.293: E/AndroidRuntime(16363): Caused by: java.lang.NullPointerException 08-20 03:23:23.293: E/AndroidRuntime(16363): at com.example.istronggyminstructor.CurrentUsers.onClick_addUser(CurrentUsers.java:118) 08-20 03:23:23.293: E/AndroidRuntime(16363): ... 14 more

    Read the article

  • Unable to resolve class in build.gradle using Android Studio 0.60/Gradle 0.11

    - by saywhatnow
    Established app working fine using Android Studio 0.5.9/ Gradle 0.9 but upgrading to Android Studio 0.6.0/ Gradle 0.11 causes the error below. Somehow Studio seems to have lost the ability to resolve the android tools import at the top of the build.gradle file. Anyone got any ideas on how to solve this? build file 'Users/[me]/Repositories/[project]/[module]/build.gradle': 1: unable to resolve class com.android.builder.DefaultManifestParser @ line 1, column 1. import com.android.builder.DefaultManifestParser 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:858) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:548) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287) at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileScript(DefaultScriptCompilationHandler.java:115) ... 77 more 2014-06-09 10:15:28,537 [ 92905] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/[me]/Repositories/[project]' org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.12-all.zip'. at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) [project]/[module]/build.gradle import com.android.builder.DefaultManifestParser apply plugin: 'android-sdk-manager' apply plugin: 'android' android { sourceSets { main { manifest.srcFile 'src/main/AndroidManifest.xml' res.srcDirs = ['src/main/res'] } debug { res.srcDirs = ['src/debug/res'] } release { res.srcDirs = ['src/release/res'] } } compileSdkVersion 19 buildToolsVersion '19.0.0' defaultConfig { minSdkVersion 14 targetSdkVersion 19 } signingConfigs { release } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' signingConfig signingConfigs.release applicationVariants.all { variant -> def file = variant.outputFile def manifestParser = new DefaultManifestParser() def wmgVersionCode = manifestParser.getVersionCode(android.sourceSets.main.manifest.srcFile) println wmgVersionCode variant.outputFile = new File(file.parent, file.name.replace("-release.apk", "_" + wmgVersionCode + ".apk")) } } } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } } def Properties props = new Properties() def propFile = file('signing.properties') if (propFile.canRead()){ props.load(new FileInputStream(propFile)) if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { println 'RELEASE BUILD SIGNING' android.signingConfigs.release.storeFile = file(props['STORE_FILE']) android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] } else { println 'RELEASE BUILD NOT FOUND SIGNING PROPERTIES' android.buildTypes.release.signingConfig = null } }else { println 'RELEASE BUILD NOT FOUND SIGNING FILE' android.buildTypes.release.signingConfig = null } repositories { maven { url 'https://repo.commonsware.com.s3.amazonaws.com' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { compile 'com.github.gabrielemariotti.changeloglib:library:1.4.+' compile 'com.google.code.gson:gson:2.2.4' compile 'com.google.android.gms:play-services:+' compile 'com.android.support:appcompat-v7:+' compile 'com.squareup.okhttp:okhttp:1.5.+' compile 'com.octo.android.robospice:robospice:1.4.11' compile 'com.octo.android.robospice:robospice-cache:1.4.11' compile 'com.octo.android.robospice:robospice-retrofit:1.4.11' compile 'com.commonsware.cwac:security:0.1.+' compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' compile 'com.android.support:support-v4:19.+' compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1+' compile 'de.greenrobot:eventbus:2.2.1+' compile project(':captureActivity') compile ('de.keyboardsurfer.android.widget:crouton:1.8.+') { exclude group: 'com.google.android', module: 'support-v4' } compile files('libs/CWAC-LoaderEx.jar') }

    Read the article

  • Fragment not showing up and breaks other buttons on Layout

    - by Devin Crane
    I'm learning how to use Fragments, and trying to add a fragment tag_button.xml at runtime to a FrameLayout tagFragmentContainer deep within another layout, deepLayout.xml. I get no errors, but the fragment doesn't show up. When I make its container visible, I can see a small sliver of layout between the other elements already existing, but then it disappears after onCreateView(), and all the remaining buttons are broken, which is even more confusing to me. tag_button.xml is just a regular layout file with some text and a button. tagFragmentContainer, within a LinearLayout in the middle of a large layout file, deepLayout.xml: <LinearLayout android:id="@+id/tagButtonsLayout" android:layout_marginBottom="10dip" android:visibility="gone" style="@style/Form"> <FrameLayout android:id="@+id/tagFragmentContainer" android:layout_marginBottom="10dip" style="@style/Form"> </FrameLayout> </LinearLayout> In deepLayoutActivity, I make visible tagButtonsLayout and start TagButtonActivity: final LinearLayout anotherlm = (LinearLayout) findViewById(R.id.tagButtonsLayout); anotherlm.setVisibility(View.VISIBLE); Intent i = new Intent (this, TagButtonActivity.class); startActivity(i); TagButtonActivity is as follows: public class TagButtonActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_expense); if (savedInstanceState != null) return; TagButtonFragment firstFragment = new TagButtonFragment(); getSupportFragmentManager().beginTransaction().add(R.id.tagFragmentContainer, firstFragment, "tagOne").commit(); } } TagButtonFragment: public class TagButtonFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.tag_button, container, false); } } tag_button.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Form"> <TextView android:id="@+id/tag_button_header" style="@style/FieldHeader" android:text="example text"/> <RelativeLayout android:id="@+id/tag_button_block" android:layout_width="match_parent" android:layout_marginLeft="2dip" android:layout_marginTop="3dip" android:layout_marginBottom="3dip" android:layout_marginRight="2dip" android:layout_height="43dip" android:clickable="true" android:background="@drawable/row_spinner_selector"> <ImageView android:id="@+id/question_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@drawable/arrow_right"/> <TextView android:id="@+id/tag_question_text" android:layout_toLeftOf="@id/question_arrow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_centerVertical="true" android:textColor="@android:color/black" android:singleLine="true" android:ellipsize="end" android:textSize="15sp" android:text="@string/not_selected"/> </RelativeLayout> </LinearLayout> I would certainly appreciate any help in figuring this out from someone who knows fragments better than me! Thanks!

    Read the article

  • Android app crashes when I change the default xml layout file to another

    - by mib1413456
    I am currently just starting to learn android development and have created a basic "Hello world" app that uses "activity_main.xml" for the default layout. I tried to create a new layout xml file called "new_layout.xml" with a text view, a text field and a button and did the following changes in the MainActivity.java file: setContentView(R.layout.new_layout); I did nothing else expect for adding a new_layout.xml in the res/layout folder, I have tried restarting and cleaning the project but nothing. Below is my activity_main.xml file, new_layout.xml file and MainActivity.java activity_main.xml: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="org.example.androidsdk.demo.MainActivity" tools:ignore="MergeRootFrame" /> new_layout.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" > <requestFocus /> </EditText> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> MainActivity.java file package org.example.androidsdk.demo; import android.app.Activity; import android.app.ActionBar; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_layout); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()) .commit(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } }

    Read the article

  • ScrollView in android

    - by rantravee
    hi, I' have a view that contains several textViews an ImageView and a Button . Because on small screen devices (or in landscape mode on big ones ) not all are visible I use a Scroll as the parent of the whole hierarchy to allow the user to view all the information. The things are suck that the button must be at the buttom of the view . However on big screen device , where it remains enough space at the buttom , the button is put immediatelly below the last textview,and seems to occupy all the remaining space (resulting in an unnactractive view) . Trying to use android:allignParentButtom ="true" not only that it has no effect but it puts the button at top of the screen . Has anyone any ideea how could I accomplish what I described ? here's the xml <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> <RelativeLayout android:id="@+id/gps_info_page1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true"> <TextView android:id="@+id/itsDateTimeValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="@string/eStrUnknown"> </TextView> <RelativeLayout android:id="@+id/directions" android:layout_centerHorizontal="true" android:layout_below="@+id/itsDateTimeValue" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/itsDirectionValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="2dip" android:textSize="20sp"> </TextView> <TextView android:id="@+id/itsOrientation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_marginLeft="2dip" android:text="@string/eStrUnknown" android:layout_toRightOf="@+id/itsDirectionValue"> </TextView> </RelativeLayout> <ImageView android:id="@+id/itsImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/compass" android:layout_below="@+id/directions" android:layout_centerHorizontal="true"> </ImageView> <RelativeLayout> ..."TextViews below the above image" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout> ..."TextViews below the above" </RelativeLayout> <RelativeLayout ..."TextViews below the above" </RelativeLayout> <LinearLayout android:id="@+id/div" android:layout_width="fill_parent" android:layout_height="1dip" android:layout_below="@+id/sunset_layout" android:background="#F333"> </LinearLayout> <Button //adding here android:alignParentBottom="true" has described above behavior android:layout_marginBottom="3dip" android:layout_marginTop="20dip" android:id="@+id/done_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/eStrDone" android:textSize="18sp" android:layout_below="@+id/div" android:layout_centerHorizontal="true"> </Button> </RelativeLayout> </ScrollView>

    Read the article

  • How to implement Google Maps new version of API v2

    - by bapatla
    Hi every one I came to know that google maps has deprecated its previous version API v1 and introduced a new version of google maps API v2. I tried out one example by following some links in google any how i am pretty sure that i got the api key correctly by providing the exact hash key code and managed to get the correct api key. Now i managed to write some code as well but when i tried to execute the code i am getting the errors please help me to solve this here is my code and i even tried the sample codes provided by google play services an i got the same problem this is the sample that i have done by referring some links in google main activity package com.example.apv; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import android.os.Bundle; import android.app.Activity; import android.app.FragmentManager; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); FragmentManager fragmentManager = getFragmentManager(); MapFragment mapFragment = (MapFragment) fragmentManager.findFragmentById(R.id.map); GoogleMap googleMap = mapFragment.getMap(); LatLng sfLatLng = new LatLng(37.7750, -122.4183); googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); googleMap.addMarker(new MarkerOptions() .position(sfLatLng) .title("San Francisco") .snippet("Population: 776733") .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); googleMap.getUiSettings().setCompassEnabled(true); googleMap.getUiSettings().setZoomControlsEnabled(true); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(sfLatLng, 10)); } } main.xml <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.MapFragment"/> and finally my manifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.apv" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/> <permission android:name="com.codebybrian.mapsample.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <!--Required permissions--> permission oid:name="com.codebybrian.mapsample.permission.MAPS_RECEIVE"/> <!--Used by the API to download map tiles from Google Maps servers: --> <uses-permission android:name="android.permission.INTERNET"/> <!--Allows the API to access Google web-based services: --> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!--Optional permissions--> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!--Version 2 of the Google Maps Android API requires OpenGL ES version 2 --> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> application android:label="@string/app_name" android:icon="@drawable/ic_launcher"> <activity android:name=".MyMapActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AZzaSSsBmhi4dXoKSylGGmjkQ5Jev9UdAJBjk"/> </application> </manifest> i run my application in emulator of version 4.2 and api level of 17 i got following error 12-17 10:06:52.590: E/Trace(826): error opening trace file: No such file or directory (2) 12-17 10:06:52.590: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 12-17 10:06:52.590: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 12-17 10:06:52.590: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 12-17 10:06:52.680: I/ActivityThread(826): Pub com.google.android.gms.plus;com.google.android.gms.plus.action: com.google.android.gms.plus.provider.PlusProvider 12-17 10:06:52.740: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 12-17 10:06:52.740: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 12-17 10:06:52.760: W/Trace(826): Unexpected value from nativeGetEnabledTags: 0 later i came to know that these version cant execute in emulator so i tried executing it with two devices one is Sony xperia u of android version 2.3.7 and Samsung galaxy tab of android version 4.1.1 and these are my outputs 12-17 14:37:02.468: D/AndroidRuntime(7636): Shutting down VM 12-17 14:37:02.468: W/dalvikvm(7636): threadid=1: thread exiting with uncaught exception (group=0x41f672a0) 12-17 14:37:02.476: E/AndroidRuntime(7636): FATAL EXCEPTION: main 12-17 14:37:02.476: E/AndroidRuntime(7636): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.apv/com.example.apv.MyMapActivity}: java.lang.ClassNotFoundException: com.example.apv.MyMapActivity 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2021) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread.access$600(ActivityThread.java:140) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.os.Handler.dispatchMessage(Handler.java:99) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.os.Looper.loop(Looper.java:137) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread.main(ActivityThread.java:4895) 12-17 14:37:02.476: E/AndroidRuntime(7636): at java.lang.reflect.Method.invokeNative(Native Method) 12-17 14:37:02.476: E/AndroidRuntime(7636): at java.lang.reflect.Method.invoke(Method.java:511) 12-17 14:37:02.476: E/AndroidRuntime(7636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller .run(ZygoteInit.java:994) 12-17 14:37:02.476: E/AndroidRuntime(7636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 12-17 14:37:02.476: E/AndroidRuntime(7636): at dalvik.system.NativeStart.main(Native Method) 12-17 14:37:02.476: E/AndroidRuntime(7636): Caused by: java.lang.ClassNotFoundException: com.example.apv.MyMapActivity 12-17 14:37:02.476: E/AndroidRuntime(7636): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 12-17 14:37:02.476: E/AndroidRuntime(7636): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 12-17 14:37:02.476: E/AndroidRuntime(7636): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.Instrumentation.newActivity(Instrumentation.java:1068) 12-17 14:37:02.476: E/AndroidRuntime(7636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2012) 12-17 14:37:02.476: E/AndroidRuntime(7636): ... 11 more could any one please suggest me to how to get this done and give me some links of new version API v2 tutorials of google maps and some examples links please help me

    Read the article

  • Please verify my layout: bottom button keeps coming up over keyboard

    - by steff
    Hi everyone, I have a layout which does almost what I want. There's just one bug regarding the button at the bottom. I should stay at the bottom at all times. But whenever I bring up the soft-keyboard the button will be displayed above the keyboard. This is not what I want but it should become covered by the keyboard. Moreover, I'd be happy if you could comment on how the layout's built. Thanks, steff <?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" android:orientation="vertical"> <LinearLayout android:id="@+id/l_layout_tags" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:text="TAGS:" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <AutoCompleteTextView android:id="@+id/actv_tags" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:imeOptions="actionDone" /> <ImageButton android:id="@+id/btn_add_tag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_input_add" android:onClick="addTag"/> </LinearLayout> <ScrollView android:id="@+id/sv_scroll_contents" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/l_layout_tags" android:scrollbarFadeDuration="2000" > <TableLayout android:id="@+id/t_layout_contents" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="1" android:paddingRight="5dip"> <TableRow android:id="@+id/tr_template"> <ImageView android:id="@+id/iv_blank" android:src="@android:color/transparent" /> <EditText android:id="@+id/et_content1" android:gravity="top" android:maxWidth="200dp" android:imeOptions="actionDone" /> </TableRow> </TableLayout> </ScrollView> <LinearLayout android:id="@+id/l_layout_media_btns" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true" android:layout_below="@id/sv_scroll_contents" > <ImageButton android:id="@+id/btn_camera" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_camera" android:onClick="takePicture" /> <ImageButton android:id="@+id/btn_video" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_camera" /> <ImageButton android:id="@+id/btn_audio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_btn_speak_now" /> <ImageButton android:id="@+id/btn_sketch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_edit" /> </LinearLayout> <ImageButton android:id="@+id/btn_save_note" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:src="@android:drawable/ic_menu_upload" /> </RelativeLayout>

    Read the article

  • Listview Row Overlap Problem

    - by rgrandy
    I just updated my app and I am getting some odd complaints from people who update it. I am only getting complaints from people with non-stock android phones (phones that manufacturers have modified...HTC phones, cliq, pulse, etc), other phones like the Droid, Nexus work fine. My app (Photo Frame Deluxe) has a list in it with a Image View, Text View, View (spacer) and checkbox, all in a row. What happens on the affected phones is that the rows start overlapping and it cuts the top half of everything off. My layout code for this is below, I am pulling my hair out on this, what might I have wrong in this layout. Why does this work on some phones and not on others? Any help would be appreciated. Row Layout: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/photorowIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingRight="5dp" /> <TextView android:id="@+id/photorowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" /> <View android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1"/> <CheckBox android:id="@+id/photorowCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:focusable="false" android:focusableInTouchMode="false" /> </LinearLayout> Layout Row is inserted in: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/title1_gradient" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Select Photos to Display:" android:textSize="20sp" android:textStyle="bold" android:textColor="#FFFFFFFF" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="5dp" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/folderName" android:textSize="15sp" android:textStyle="bold" android:textColor="#FFFFFFFF" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingBottom="5dp" /> <View android:layout_width="fill_parent" android:layout_height="1px" android:background="#406C6C6C"/> </LinearLayout> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" android:drawSelectorOnTop="false" android:paddingLeft="5dp" android:paddingRight="5dp" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="bottom"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="bottom" android:background="#FF6C6C6C" android:padding="5dp"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ok" android:text="OK"/> </LinearLayout> </LinearLayout> </LinearLayout>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >