Search Results

Search found 911 results on 37 pages for 'textview'.

Page 13/37 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Android Actionbar Tabs + Fragments + Service

    - by Vladimir
    So, I have 3 problems with my code: 1) I want that each tab saves its state. So that a TextView shows changed text if it was changed. 2) if I go to Tab2 then to Tab1 I can't see the content of the fragments. Only if I touch on the already selected tab, it shows me the content 3) I can't correctly connect/bind and unbind service to Fragment Text must be changed from Service. Please help, I don't know how I realize my intent. MyActivity.java package com.example.tabs; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyActivity extends Activity { private static String ACTION_BAR_INDEX = "ACTION_BAR_INDEX"; private Tab tTab1; private Tab tTab2; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private TabListener<Tab1> tab1Listener; private TabListener<Tab2> tab2Listener; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { } } } }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myServiceIntent = new Intent(this, MyService.class); bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); if (!isServiceRunning()) { startService(myServiceIntent); } final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); tTab1 = actionBar.newTab(); tab1Listener = new TabListener<Tab1>(this, R.id.fl_main, Tab1.class); tTab1.setTag("Tab_1"); tTab1.setText("Tab_1"); tTab1.setTabListener(tab1Listener); tTab2 = actionBar.newTab(); tab2Listener = new TabListener<Tab2>(this, R.id.fl_main, Tab2.class); tTab2.setTag("Tab_2"); tTab2.setText("Tab_2"); tTab2.setTabListener(tab2Listener); actionBar.addTab(tTab1, 0); actionBar.addTab(tTab2, 1); } @Override public void onResume() { super.onResume(); SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); } protected void onSaveInstanceState(Bundle outState) { // Save the current Action Bar tab selection int actionBarIndex = getActionBar().getSelectedTab().getPosition(); SharedPreferences.Editor editor = getPreferences(Activity.MODE_PRIVATE).edit(); editor.putInt(ACTION_BAR_INDEX, actionBarIndex); editor.apply(); // Detach each of the Fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); if (tab2Listener.fragment != null) { ft.detach(tab2Listener.fragment); } if (tab1Listener.fragment != null) { ft.detach(tab1Listener.fragment); } ft.commit(); super.onSaveInstanceState(outState); } protected void onRestoreInstanceState(Bundle savedInstanceState) { // Find the recreated Fragments and assign them to their associated Tab // Listeners. tab1Listener.fragment = getFragmentManager().findFragmentByTag(Tab1.class.getName()); tab2Listener.fragment = getFragmentManager().findFragmentByTag(Tab2.class.getName()); // Restore the previous Action Bar tab selection. SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); super.onRestoreInstanceState(savedInstanceState); } public boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MyService.class.getName().equals(service.service.getClassName())) { return true; } } return false; } @Override protected void onDestroy() { super.onDestroy(); unbindService(myConnection); stopService(myServiceIntent); } public static class TabListener<T extends Fragment> implements ActionBar.TabListener { private Fragment fragment; private Activity activity; private Class<T> fragmentClass; private int fragmentContainer; public TabListener(Activity activity, int fragmentContainer, Class<T> fragmentClass) { this.activity = activity; this.fragmentContainer = fragmentContainer; this.fragmentClass = fragmentClass; } public void onTabReselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.attach(fragment); } } public void onTabSelected(Tab tab, FragmentTransaction ft) { if (fragment == null) { String fragmentName = fragmentClass.getName(); fragment = Fragment.instantiate(activity, fragmentName); ft.add(fragmentContainer, fragment, fragmentName); } else { ft.detach(fragment); } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.detach(fragment); } } } } MyService.java package com.example.tabs; import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyService extends Service { private final IBinder myBinder = new MyBinder(); private static Handler myServiceHandler; public IBinder onBind(Intent intent) { return myBinder; } public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); return START_STICKY; } public void sendMessage(String sText, int id) { Bundle bundle = new Bundle(); bundle.putString("Text" + id, sText); Message bundleMessage = new Message(); bundleMessage.setData(bundle); myServiceHandler.sendMessage(bundleMessage); } public class MyBinder extends Binder { public MyService getService() { return MyService.this; } public void setCallbackHandler(Handler myActivityHandler) { myServiceHandler = myActivityHandler; } public void removeCallbackHandler() { myServiceHandler = null; } } } Tab1.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab1 extends Fragment { public static String TAG = Tab1.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab1, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab1); editText = (EditText) view.findViewById(R.id.editText1); Button btn1 = (Button) view.findViewById(R.id.btn_change_text_1); btn1.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 1); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } Tab2.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab2 extends Fragment { public static String TAG = Tab2.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab2, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab2); editText = (EditText) view.findViewById(R.id.editText2); Button btn2 = (Button) view.findViewById(R.id.btn_change_text_2); btn2.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 2); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical" > </LinearLayout> tab1.xml <LinearLayout 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:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TAB1\nTAB1\nTAB1" /> </LinearLayout> tab2.xml <LinearLayout 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:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="TAB2\nTAB2\nTAB2" /> </LinearLayout> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tabs" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <activity android:name="com.example.tabs.MyActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MyService" android:enabled="true" > </service> </application> </manifest>

    Read the article

  • Android layout issue - relative widths in percent using weight

    - by cdonner
    I am trying to assign relative widths to columns in a ListView that is in a TabHost, using layout_weight as suggested here: <?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"> <TableLayout android:id="@+id/triplist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="4px"> <TableRow> <ListView android:id="@+id/triplistview" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </TableRow> <TableRow> <Button android:id="@+id/newtripbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Trip"/> </TableRow> [other tabs ...] My row definition has 4 columns that I would like to size as follows: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="1.0" android:padding="4px"> <TextView android:id="@+id/rowtripdate" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content" android:inputType="date"/> <TextView android:id="@+id/rowodostart" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content"/> <TextView android:id="@+id/rowodoend" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content"/> <TextView android:id="@+id/rowcomment" android:layout_weight=".4" android:layout_width="0dip" android:layout_height="wrap_content"> Unfortunately, it seems to want to fit all the columns into the space that the button occupies, as opposed to the width of the screen. Or maybe there is another constraint that I do not understand. I'd appreciate your help.

    Read the article

  • Android: failed to setContentView when switching to ListActivity

    - by Yang
    This is an follow-up issue on my previous question http://stackoverflow.com/questions/2548304/android-which-view-should-i-use-for-showing-text-and-image I read the article about creating ListView for LinearLayout. However, my following code failed at the setContentView() function when I changed "extends Activity" to "extends ListActivity", any idea why? private TextView mSelection; //private ImageView mImages; static final String[] keywords = new String[]{"China", "Japan", "USA", "Canada"}; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.contactLayout); mSelection = (TextView)findViewById(R.id.ContactNames); ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.contactlayout, R.id.ContactNames,keywords); setListAdapter(adapter); } My Layout is from this article: http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/icon" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/ContactNames" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" android:text="My Application" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleLine="true" android:ellipsize="marquee" android:text="Simple application that shows how to use RelativeLayout" /> </LinearLayout>

    Read the article

  • Newbie: How to set attribute of the relative layout in my case??

    - by Leem
    I would like to divide my screen into 4 equal areas like ?.Each one of the four area is a linear layout. I tried to use relative layout to hold four linear layout like 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"> <LinearLayout android:id="@+id/up_left_area" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ffff66" > <TextView android:id="@+id/label1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="UP LEFT"/> </LinearLayout> <LinearLayout android:id="@+id/up_right_area" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/up_left_area" android:background="#ccffff"> <TextView android:id="@+id/label2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="UP RIGHT"/> </LinearLayout> <LinearLayout android:id="@+id/down_left_area" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_below="@id/up_left_area" android:background="#66cc33" > <TextView android:id="@+id/label3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="DOWN LEFT"/> </LinearLayout> <LinearLayout android:id="@+id/down_right_area" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/up_right_area" android:layout_toRightOf="@id/down_left_area" android:background="#cc6600"> <TextView android:id="@+id/label4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="DOWN RIGHT"/> </LinearLayout> </RelativeLayout> With the above xml layout code, I do get 4 areas on the screen, but they are not equal sized. How to modify my code to have equal sized 4 areas on the screen like ? ?

    Read the article

  • Multiple choice list with custom view?

    - by Po
    I've seen example com.example.android.apis.view.List11 from ApiDemos. In that example, each row takes the view android.R.simple_list_item_multiple_choice. Each such view has a TextView and a CheckBox. Now I want each view to have 2 TextView's and 1 CheckBox, somewhat similar to the List3 example. I tried creating a custom layout file row.xml like this: <?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="fill_parent" > <CheckBox android:id="@+id/checkbox" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="fill_parent" /> <TextView android:id="@+id/text_name" android:textSize="13px" android:textStyle="bold" android:layout_toLeftOf="@id/checkbox" android:layout_alignParentLeft="true" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/text_phone" android:textSize="9px" android:layout_toLeftOf="@id/checkbox" android:layout_below="@id/text_name" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </RelativeLayout> Then in Activity.onCreate(), I do like this: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Query the contacts mCursor = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null); startManagingCursor(mCursor); ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.row, mCursor, new String[] { Phones.NAME, Phones.NUMBER}, new int[] { R.id.text_name, R.id.text_phone }); setListAdapter(adapter); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); } The result kind of looks like what I want, but it looks like the list doesn't know which item of it is selected. Also, I need to click exactly on the checkbox. In the List11 example, I only need to click on the item row. So what do I need to do to make a multiple choice list with my custom view for each row? Many thanks.

    Read the article

  • Objective C - displaying data in NSTextView

    - by Leo
    Hi, I'm having difficulties displaying data in a TextView in iPhone programming. I'm analyzing incoming audio data (from the microphone). In order to do that, I create an object "analyzer" from my SignalAnalyzer class which performs analysis of the incoming data. What I would like to do is to display each new incoming data in a TextView in realtime. So when I push a button, I create the object "analyzer" whiwh analyze the incoming data. Each time there is new data, I need to display it on the screen in a TextView. My problem is that I'm getting an error because (I think) I'm trying to send a message to the parent class (the one taking care of displaying stuff in my TextView : it has a TexView instance variable linked in Interface Builder). What should I do in order to tell my parent class what it needs to display ? Or how sohould I design my classes to display automaticlally something ? Thank you for your help. PS : Here is my error : 2010-04-19 14:59:39.360 MyApp[1421:5003] void WebThreadLockFromAnyThread(), 0x14a890: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread. 2010-04-19 14:59:39.369 MyApp[1421:5003] bool _WebTryThreadLock(bool), 0x14a890: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... Program received signal: “EXC_BAD_ACCESS”.

    Read the article

  • Contact-app like scrollinglist on android

    - by Alxandr
    I'm writing my first android app (I'm a noob at android, but decent at java). The first screen of the app consists of a huge list (about 1.5K items) of Manga-objects. The code I use is as following: main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ListView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/android:list"></ListView> <TextView android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="@string/list_no_items" android:id="@+id/android:empty"></TextView> </LinearLayout> row.xml: <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/icon" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/toptext" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/bottomtext" android:singleLine="true" android:ellipsize="marquee" /> </LinearLayout> </LinearLayout> Then I have a adapter which basically takes a Manga-object and puts it's name in the rows toptext, and it's latest updated date in the bottomtext. However, (this might be caused by the virtualization of the unit though), the result is really slow. Scrolling the list takes forever and you can only scroll small peaces of the time. How can I make the list work like the one in the contacts-app? So that when you start scrolling a handle pops out at the right side of the screen, and when you drag it letters shows up as of how far you've scrolled (the list is sorted alphabetically), and also, is there a way I could improve the performance of the list?

    Read the article

  • Android layout issue - relative widths

    - by cdonner
    I am trying to assign relative widths to columns in a ListView that is in a TabHost, using layout_weight as suggested here: <?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"> <TableLayout android:id="@+id/triplist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="4px"> <TableRow> <ListView android:id="@+id/triplistview" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </TableRow> <TableRow> <Button android:id="@+id/newtripbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Trip"/> </TableRow> [other tabs ...] My row definition has 4 columns that I would like to size as follows: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="1.0" android:padding="4px"> <TextView android:id="@+id/rowtripdate" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content" android:inputType="date"/> <TextView android:id="@+id/rowodostart" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content"/> <TextView android:id="@+id/rowodoend" android:layout_weight=".2" android:layout_width="0dip" android:layout_height="wrap_content"/> <TextView android:id="@+id/rowcomment" android:layout_weight=".4" android:layout_width="0dip" android:layout_height="wrap_content"> Unfortunately, it seems to want to fit all the column into the space that the button occupies, as opposed to the width of the screen. Or maybe there is another constraint that I do not understand. I'd appreciate your help.

    Read the article

  • Problem with TextViews running into each other in RelativeLayout

    - by Janusz
    I have a problem with two Textviews on the same height in a RelativeLayout running into each other. I use the following Layout. <?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/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerInside" android:src="@drawable/icon" /> <TextView android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="NameNameNameNameNameNameName" android:layout_alignParentTop="true" android:layout_toRightOf="@id/logo" android:gravity="clip_horizontal" android:lines="1" /> <TextView android:id="@+id/information" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="information" android:layout_alignParentRight="true" android:layout_alignParentTop="true" /> <TextView android:id="@+id/nrcoupons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Number" android:layout_alignRight="@id/information" android:layout_alignBottom="@id/logo" /> <TextView android:id="@+id/subcategory" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Subcategory" android:layout_alignLeft="@id/name" android:layout_alignBottom="@id/logo" /> </RelativeLayout> This gives me this view: Everything is as I need it except the two textviews name and information are displayed on the same screen space with the one on top of the other. How can I avoid this?

    Read the article

  • Hello, TabWidget each tab refer to new xml

    - by Clozecall
    Hey everyone I'm using Google's exmaple of Hello, TabWidget but altered it to look like this: main.xml: <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"> <TextView android:text="@+layout/text" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <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> java file: public class HelloTabWidget extends TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost mTabHost = getTabHost(); mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.layout.text)); mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2)); mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3)); mTabHost.setCurrentTab(0); } } and here is the text.xml in res/layout: <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="This is Tab 1" /> What I'm basically trying to do is have each tab refer to its own xml file rather than all in main.xml, but the text in the first tab doesn't show up.

    Read the article

  • Android how to use checkedtextview

    - by erdomester
    the title speaks for itself. I am over several articles, topics and still haven't figured out how to use checkedtextview. I want a listview with checkable items. In the following code i am using a listview and populating it with a string array. But how to change it to checkedtextview? delete.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="4dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/linlay0" android:background="@color/list_bg"> <TextView android:id="@+id/TextView00" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#D8D8D8" android:textColor="#424242" android:gravity="center_horizontal|center_vertical" android:textSize="20px" android:height="40px" android:textStyle="bold" /> <ListView android:id="@+id/ListView01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> delete_lv.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/list_content" android:textColor="#222222" android:gravity="center" android:text="sample" android:layout_margin="4dip" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> Delete.java: public class Delete extends Activity { ListView lv1; ArrayAdapter<String> adapter1; private String lv_items[] = { "Android", "iPhone", "BlackBerry", "AndroidPeople", "J2ME", "Listview", "ArrayAdapter", "ListItem", "Us", "UK", "India" }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.delete); TextView tv0 = (TextView)findViewById(R.id.TextView00); tv0.setText("Deletes"); lv1 = (ListView) findViewById(R.id.ListView01); adapter1 = new ArrayAdapter<String>(Delete.this,R.layout.list_black_text,R.id.list_content, lv_items); lv1.setAdapter(adapter1); adapter1.notifyDataSetChanged(); } }

    Read the article

  • Android -Layout Manager not showing buttons

    - by Arun
    The following is my code. I want an interface where I have a single line textbox, a multiline textbox with 2 buttons below. I want the multiline textbox to occupy all the space available after rendering the buttons and textbox. For this I created two LinearLayouts inside the main layout. The first one has vertical orientation with layout_width set to fill_parent. The second one is horizontal with fill_parent again. The first one has a textbox for which I have set the layout_height to fill parent. The second one has two textboxes OK and Cancel. When I run this application I get the UI, but the Buttons are very small. I have to set the button height manually. What am I doing wrong here. I don't want to hard code the button height. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" 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:layout_weight="1"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Name"></TextView> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Contents"></TextView> <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> <Button android:id="@+id/okbutt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="OK" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Cancel" android:layout_weight="1" /> </LinearLayout> Thanks, Arun

    Read the article

  • Android - Linear Layout arrangement, not positioning as expected

    - by Arun
    The following is my code. I want an interface where I have a single line textbox, a multiline textbox with 2 buttons below. I want the multiline textbox to occupy all the space available after rendering the buttons and textbox. For this I created two LinearLayouts inside the main layout. The first one has vertical orientation with layout_width set to fill_parent. The second one is horizontal with fill_parent again. The first one has a textbox for which I have set the layout_height to fill parent. The second one has two textboxes OK and Cancel. When I run this application I get the UI, but the Buttons are very small (about 5px in height). I have to set the button height manually. What am I doing wrong here. I don't want to hard code the button height. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" 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:layout_weight="1"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Name"></TextView> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Contents"></TextView> <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> <Button android:id="@+id/okbutt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="OK" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Cancel" android:layout_weight="1" /> </LinearLayout> Thanks, Arun

    Read the article

  • Cant get a location

    - by user1891806
    Iam trying to get a location (latitute and longitude), I cant figure out what Im doing wrong but my location keeps returning null. Anybody knows what I am doing wrong? public class ParseJSON extends Activity implements LocationListener { private TextView latituteField; private TextView longitudeField; LocationManager lm; String provider; int lat; int lon; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria crit = new Criteria(); provider = lm.getBestProvider(crit, false); Location location = lm.getLastKnownLocation(provider); if (location != null){ lat = (int) location.getLatitude(); lon = (int) location.getLongitude(); latituteField = (TextView) findViewById(R.id.lattest); longitudeField = (TextView) findViewById(R.id.lontest); latituteField.setText(lat); longitudeField.setText(String.valueOf(lon)); } else { Toast.makeText(ParseJSON.this, "Couldnt get location", Toast.LENGTH_SHORT); } String readWeatherFeed = readWeatherFeed(); try { JSONArray jsonArray = new JSONArray(readWeatherFeed); Log.i(ParseJSON.class.getName(), "Number of entries " + jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Log.i(ParseJSON.class.getName(), jsonObject.getString("text")); } } catch (Exception e) { e.printStackTrace(); } } I dont have a clue, thanks in advance

    Read the article

  • Android custom xml widget

    - by DrogoNevets
    I have an XML file in my layout folder that has how i want my custom widget/view (not sure what correct terminology is here). but how do i make it so that i can programatically, add one or more to an activity the xml file is as follows <?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:id="@+id/viewLog"> <TextView android:id="@+id/viewLogClimbName" android:layout_width="fill_parent" android:singleLine="true" android:ellipsize="end" android:gravity="left" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/viewLogDate" android:layout_width="fill_parent" android:singleLine="true" android:ellipsize="end" android:gravity="left" /> <TextView android:id="@+id/viewLogStyle" android:layout_width="fill_parent" android:singleLine="true" android:ellipsize="end" android:gravity="left" /> </LinearLayout> <TextView android:id="@+id/viewLogDetails" android:layout_width="fill_parent" android:layout_height="fill_parent" android:ellipsize="end" android:gravity="left" android:layout_weight="1" /> </LinearLayout> </LinearLayout> I have looked at the android how-to and dont really understand what its getting at

    Read the article

  • RelativeLayout differences between 1.5 and 2.1

    - by Kilnr
    I've got a ListView with items composed of RelativeLayouts. This is the relevant XML from the list items: <?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="wrap_content"> <TextView android:id="@+id/xx" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_centerInParent="true" android:layout_alignParentLeft="true"/> <TextView android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/xx" /> <TextView android:id="@+id/tag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/xx" android:layout_below="@id/title" /> <TextView android:id="@+id/subtitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/tag" android:layout_below="@id/title" /> </RelativeLayout> On Android 2.1 (tested on a Nexus One), this shows the desired behavior: On Android 1.5 however (tested on a HTC Hero), it shows up like this: [edit] On 1.6 (emulator), it works as expected as well. The small grey line on the top left is what shows up in the first pic as "xx", so that should be vertically centered. As far as I can see, the XML dictates this, but for some reason, 1.5 ignores it. Why is this? I can't find anything about this difference, and I've been brute forcing any combination of layout_center, center, alignParent*, but to no avail... Can anyone shed some light on this? Thanks!

    Read the article

  • findViewById returns null in new Intent

    - by drozzy
    I am having a problem where in the started Intent, the findViewById returns null. Is there anything special I should know about starting a new intent? It goes something like this for me: //in the MainList class Intent stuffList = new Intent(this, StuffList.class); then in the new Stuff's constructor: public class StuffList extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.stuff_list); ... this.setListAdapter(new StuffAdapter(this, my_cursor)); and in the StuffAdapter I do my usual view and data retrieval. Note the line where findViewById returns null: class ViewWrapper{ View base; TextView label = null; ViewWrapper(View base){ this.base = base; } TextView getLabel(){ if(label == null){ label = (TextView)base.findViewById(R.id.my_label); // returns NULL } return label;} } class StuffAdapter extends CursorAdapter{ StuffAdapter(Context context, Cursor cursor){ super(context, cursor); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { LayoutInflater inflater = getLayoutInflater(); View row = inflater.inflate(R.layout.stuff_list, parent, false); ViewWrapper wrapper = new ViewWrapper(row); row.setTag(wrapper); return(row); } @Override public void bindView(View row, Context context, Cursor cursor) { ViewWrapper wrapper = (ViewWrapper)row.getTag(); TextView label = wrapper.getLabel(); // also NULL //this throws exception of course label.setText(cursor.getString("title")); } } The curious thing is that in the class that calls intent (MainList class), I do Exactly the same thing (i list a bunch of objects), and it Works! however when I try to do it in an Intent - it can't seem to find the view by id.

    Read the article

  • Android custom view - setting it to take up max space available but no more

    - by Rich
    I have a custom View class in my app that I'm using in xml layouts. Wherever I'm using this view in my xml, I don't want it to stretch it's container, but I want it to fill out whatever space is available. Here's an example to make it a little clearer. I have a LinearLayout set to horizontal orientation with my custom view followed by a TextView. The TextView is going to stretch the LinearLayout so that it takes up the space it needs and no more. I want my custom view to take up the vertical space that the TextView has made available. Let's say the TextView ends up being 50px tall because of it's contents. The LinearLayout is thus stretched to about this height (not taking into account any margins or padding), so I just want the view to know it can stretch to that height and not "push on" its container. Without overriding and of the measurement methods of the base class (onMeasure, etc) my View is actually stretching to take up as much space as possible. I have already played around with wrap_content and fill_parent a bunch, so I'm assuming I need to do something in one of the View class' measure methods.

    Read the article

  • What am I missing in the following buttons code?

    - by Ayush Goyal
    I am trying to increment and decrement the middle textview via buttons on the sides. The application starts up finely but by the time I click on any of the buttons it gets closed with following error. Error: process <package> has stopped unexpectedly. My main.xml: <?xml version="1.0" encoding="utf-8"?> <Button android:id="@+id/button1" android:layout_width="50dp" android:layout_height="250dp" android:text="+" android:textSize="40dp" /> <TextView android:id="@+id/tv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:textSize="80dp" android:layout_toRightOf="@+id/button1" android:layout_marginTop="75dp" android:layout_marginLeft="80dp" /> <Button android:id="@+id/button2" android:layout_width="50dp" android:layout_height="250dp" android:layout_alignParentRight="true" android:text="-" android:textSize="40dp" /> My java file: public class IncrementDecrementActivity extends Activity { int counter; Button add, sub; TextView tv; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); add = (Button) findViewById(R.id.button1); sub = (Button) findViewById(R.id.button2); tv = (TextView) findViewById(R.id.tv1); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { counter++; tv.setText(counter); } }); sub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { counter--; tv.setText(counter); } }); } }

    Read the article

  • diffuculty in appending images dynamically in an Custom List View

    - by ganesh
    Hi I have written an custom List view which binds images according to the result from a feed @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.row_for_stopnames, null); holder = new ViewHolder(); holder.name = (TextView)convertView.findViewById(R.id.stop_name); holder.dis = (TextView)convertView.findViewById(R.id.distance); holder.route_one=(ImageView)convertView.findViewById(R.id.one); holder.route_two=(ImageView)convertView.findViewById(R.id.two); holder.route_three=(ImageView)convertView.findViewById(R.id.three); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(elements.get(position).get("stop_name")); holder.dis.setText(elements.get(position).get("distance")); String[] route_txt=elements.get(position).get("route_name").split(","); for(int i=0;i<route_txt.length;i++) { if(i==0) { holder.route_one.setBackgroundResource(Utils.getRouteImage().get(stop_txt[0])); } else if(i==1) { holder.route_two.setBackgroundResource(Utils.getRouteImage().get(stop_txt[1])); } else if(i==2) { holder.route_three.setBackgroundResource(Utils.getRouteImage().get(stop_txt[2])); } } convertView.setOnClickListener(new OnItemClickListener(position,elements)); return convertView; } class ViewHolder { TextView name; TextView dis; ImageView route_one; ImageView route_two; ImageView route_three; } for every stop name there may be route_names, maximum of three routes.I have to bind images according to the number of route names.This is what I tried to do by the above code .This works fine until I start scrolling up and down .When I do so the route images gets displayed where it does not want to be,this behaviour is unpredictable.I will be glad if someone explain me why this happens,and the best way to do this.The getRouteImage method of Utils class returns HashMap with key String and value a drawable

    Read the article

  • how to scroll in android???

    - by antony
    I create a program to add check boxes dynamically.But i cant scroll down.I add the code here ,Pls HELP...... package dyntodo.pack; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Button; import android.widget.TextView; public class dynact extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView)findViewById(R.id.textview); final EditText task = (EditText)findViewById(R.id.task); Button add = (Button)findViewById(R.id.add); add.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { addTask(task.getText().toString()); } }); } public void addTask(String task) { LinearLayout layout = (LinearLayout) findViewById(R.id.layout); final CheckBox chk = new CheckBox(this); //Creating checkbox objects….. chk.setText(task); layout.addView(chk); chk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { chk.setVisibility(5); } }); } }

    Read the article

  • GPS not update location after close and reopen app on android

    - by mrmamon
    After I closed my app for a while then reopen it again,my app will not update location or sometime it will take long time( about 5min) before update. How can I fix it? This is my code private LocationManager lm; private LocationListener locationListener; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new mLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, locationListener); } private class myLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { if (loc != null) { TextView gpsloc = (TextView) findViewById(R.id.widget28); gpsloc.setText("Lat:"+loc.getLatitude()+" Lng:"+ loc.getLongitude()); } } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub TextView gpsloc = (TextView) findViewById(R.id.widget28); gpsloc.setText("GPS OFFLINE."); } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } }

    Read the article

  • how to show all added items into another activity, like: AddtoCart and ViewCart Functionality

    - by Stanley
    i am trying to make a shopping cart app, allowing user to choose category then select item to purchase, once user will click on any item to purchase, then showing that selected item into another activity with item image, name, cost, qty (to accept by user) and also providing add to cart functionality, now i want whenever user will click on Add to Cart button, then selected item need to show in ViewCart Activity, so here i am placing my AddtoCart Activity code, please tell me what i need to write to show added item(s) into ViewCart Category just like in shopping cart, In ViewCart activity i just want to show item title, cost and qty (entered by user):- public class AddtoCart extends Activity{ static final String KEY_TITLE = "title"; static final String KEY_COST = "cost"; static final String KEY_THUMB_URL = "imageUri"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single); Intent in = getIntent(); String title = in.getStringExtra(KEY_TITLE); String thumb_url = in.getStringExtra(KEY_THUMB_URL); String cost = in.getStringExtra(KEY_COST); ImageLoader imageLoader = new ImageLoader(getApplicationContext()); ImageView imgv = (ImageView) findViewById(R.id.single_thumb); TextView txttitle = (TextView) findViewById(R.id.single_title); TextView txtcost = (TextView) findViewById(R.id.single_cost); txttitle.setText(title); txtcost.setText(cost); imageLoader.DisplayImage(thumb_url, imgv); // Save a reference to the quantity edit text final EditText editTextQuantity = (EditText) findViewById(R.id.edit_qty); ImageButton addToCartButton = (ImageButton) findViewById(R.id.img_add); addToCartButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Check to see that a valid quantity was entered int quantity = 0; try { quantity = Integer.parseInt(editTextQuantity.getText() .toString()); if (quantity <= 0) { Toast.makeText(getBaseContext(), "Please enter a quantity of 1 or higher", Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { Toast.makeText(getBaseContext(), "Please enter a numeric quantity", Toast.LENGTH_SHORT).show(); return; } // Close the activity finish(); } }); }}

    Read the article

  • TextColor not showing when row backgroundcolor set

    - by RuAware
    if my row is colored red the text wont set to green and bold italic. When debugging I can see it telling the TextView to set each textViews setting. Thanks TableRow row = new TableRow(getContext()); row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); String[] items = list.get(l).split(":"); for(int i=0; i < items.length; i++){ //see if i need to colour row if(items[i].startsWith("colorme_") == true) { if (items[i].substring(8).equals("red") == true) { row.setBackgroundColor(Color.RED); } } else { //create a temp textview then add to row TextView tempTV = new TextView(getContext()); tempTV.setText(items[i].toString()); //test against correct answers and colour text view green if correct if (correctAnswers != null && correctAnswers.size() > i) { if (correctAnswers.get(i).equals(items[i].toString()) == true) { tempTV.setTextColor(Color.GREEN); tempTV.setTypeface(null, Typeface.BOLD_ITALIC); } } row.addView(tempTV,lpTextView); } } //add the row tempTable.addView(row);

    Read the article

  • highlight listview items android

    - by user1752939
    I have listview with custom base adapter. When I populate the list I have to check a boolean in the object I'm populating the listview and if it is true to change the background color of that row. public View getView(int position, View convertView, ViewGroup parent) { LoginsList entry = listOfLoginsLists.get(position); if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.lists_row, null); } TextView ListName = (TextView) convertView.findViewById(R.id.tvListName); ListName.setText(entry.getListName()); TextView ListDescription = (TextView) convertView.findViewById(R.id.tvListDescription); ListDescription.setText(entry.getListDescription()); Button Send = (Button) convertView.findViewById(R.id.bSend); Send.setOnClickListener(this); Send.setTag(entry); RelativeLayout RelLayout = (RelativeLayout) convertView.findViewById(R.id.layoutListsRow); RelLayout.setFocusableInTouchMode(false); RelLayout.setFocusable(false); RelLayout.setOnClickListener(this); RelLayout.setTag(entry); if (entry.isSent()) { RelLayout.setBackgroundColor(Color.parseColor("#4400FF00")); } return convertView; } But this code doesn't work right. When I scroll the list view the rows colors get messed up.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >