Search Results

Search found 12558 results on 503 pages for 'android notifications'.

Page 31/503 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Android: Alignment of four squares

    - by metter
    Hello There I am trying to align four equally sized squares on an Android Screen & I have now tried what feels like a million different approaches, yet none of them seem to work :(. What I've got at the moment is the following: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/MasterLayout" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="#FFFFFF" <TableRow android:layout_weight="1" android:background="#BBBBBB" android:padding="0dip"> <TableRow android:layout_weight="1" android:padding="0dip"> This basically does the job. However, every one of those four Images has a huge padding above and under it. How do I get rid of that? Or do I need to use a different Layout type alltogether? To help illustrate my problem, here's a picture. On the left is what I got, on the right is what I need. Image Thank you very much! Cheers, Markus!

    Read the article

  • AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'... after making selection

    - by user244190
    I am using the following code to set the adapter (SimpleCursorAdapter) for an AutoCompleteTextView mComment = (AutoCompleteTextView) findViewById(R.id.comment); Cursor cComments = myAdapter.getDistinctComments(); scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1}); mComment.setAdapter(scaComments); auto_complete_item.xml <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> and thi is the xml for the actual control <AutoCompleteTextView android:id="@+id/comment" android:hint="@string/COMMENT" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18dp"/> The dropdown appears to work correctly, and shows a list of items. When I make a selection from the list I get a sqlite object ('android.database.sqlite.SQLiteCursor@'... ) in the textview. Anyone know what would cause this, or how to resolve this? thanks Ok I am able to hook into the OnItemClick event, but the TextView.setText() portion of the AutoCompleteTextView widget is updated after this point. The OnItemSelected() event never gets fired, and the onNothingSelected() event gets fired when the dropdown items are first displayed. mComment.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter(); String str = getSpinnerSelectedValue(sca,arg2,"comment"); TextView txt = (TextView) arg1; txt.setText(str); Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show(); } }); mComment.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show(); } }); Anyone alse have any ideas on how to override the updating of the TextView? thanks patrick

    Read the article

  • How to Get user input from a Text Entry Box in Android?

    - by NewGuy
    in an android website, I found an article about how to create a text entry widget that provides auto-complete suggestions. (Following is the link to the site; and it shows all the codes). http://developer.android.com/resources/tutorials/views/hello-autocomplete.html Can anyone please tell me how I can capture the input entered by the user? For example, if the user chooses “Canada”, is there a way I can know the result in the “HelloAutoComplete.java” activity? Any help would be greatly appreciated. public class HelloAutoComplete extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country); String[] countries = getResources().getStringArray(R.array.countries_array); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, countries); textView.setAdapter(adapter); textView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (adapterView.getItemAtPosition(i).toString().equals("Canada")) { Toast.makeText(getApplicationContext(), "Result Canada", Toast.LENGTH_SHORT).show(); } //Does not get an out put when I select Canada. } public void onNothingSelected(AdapterView<?> adapterView) { } }); } }

    Read the article

  • Error in code of basic game using multiple sprites and surfaceView [on hold]

    - by Khagendra Nath Mahato
    I am a beginner to android and i was trying to make a basic game with the help of an online video tutorial. I am having problem with the multi-sprites and how to use with surfaceview.The application fails launching. Here is the code of the game.please help me. package com.example.killthemall; import java.util.ArrayList; import java.util.List; import java.util.Random; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Rect; import android.os.Bundle; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.widget.Toast; public class Game extends Activity { KhogenView View1; @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); while(true){ try { OurThread.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }} } Thread OurThread; int herorows = 4; int herocolumns = 3; int xpos, ypos; int xspeed; int yspeed; int herowidth; int widthnumber = 0; int heroheight; Rect src; Rect dst; int round; Bitmap bmp1; // private Bitmap bmp1;//change name public List<Sprite> sprites = new ArrayList<Sprite>() { }; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); View1 = new KhogenView(this); setContentView(View1); sprites.add(createSprite(R.drawable.image)); sprites.add(createSprite(R.drawable.bad1)); sprites.add(createSprite(R.drawable.bad2)); sprites.add(createSprite(R.drawable.bad3)); sprites.add(createSprite(R.drawable.bad4)); sprites.add(createSprite(R.drawable.bad5)); sprites.add(createSprite(R.drawable.bad6)); sprites.add(createSprite(R.drawable.good1)); sprites.add(createSprite(R.drawable.good2)); sprites.add(createSprite(R.drawable.good3)); sprites.add(createSprite(R.drawable.good4)); sprites.add(createSprite(R.drawable.good5)); sprites.add(createSprite(R.drawable.good6)); } private Sprite createSprite(int image) { // TODO Auto-generated method stub bmp1 = BitmapFactory.decodeResource(getResources(), image); return new Sprite(this, bmp1); } public class KhogenView extends SurfaceView implements Runnable { SurfaceHolder OurHolder; Canvas canvas = null; Random rnd = new Random(); { xpos = rnd.nextInt(canvas.getWidth() - herowidth)+herowidth; ypos = rnd.nextInt(canvas.getHeight() - heroheight)+heroheight; xspeed = rnd.nextInt(10 - 5) + 5; yspeed = rnd.nextInt(10 - 5) + 5; } public KhogenView(Context context) { super(context); // TODO Auto-generated constructor stub OurHolder = getHolder(); OurThread = new Thread(this); OurThread.start(); } @Override public void run() { // TODO Auto-generated method stub herowidth = bmp1.getWidth() / 3; heroheight = bmp1.getHeight() / 4; boolean isRunning = true; while (isRunning) { if (!OurHolder.getSurface().isValid()) continue; canvas = OurHolder.lockCanvas(); canvas.drawRGB(02, 02, 50); for (Sprite sprite : sprites) { if (widthnumber == 3) widthnumber = 0; update(); getdirection(); src = new Rect(widthnumber * herowidth, round * heroheight, (widthnumber + 1) * herowidth, (round + 1)* heroheight); dst = new Rect(xpos, ypos, xpos + herowidth, ypos+ heroheight); canvas.drawBitmap(bmp1, src, dst, null); } widthnumber++; OurHolder.unlockCanvasAndPost(canvas); } } public void update() { try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (xpos + xspeed <= 0) xspeed = 40; if (xpos >= canvas.getWidth() - herowidth) xspeed = -50; if (ypos + yspeed <= 0) yspeed = 45; if (ypos >= canvas.getHeight() - heroheight) yspeed = -55; xpos = xpos + xspeed; ypos = ypos + yspeed; } public void getdirection() { double angleinteger = (Math.atan2(yspeed, xspeed)) / (Math.PI / 2); round = (int) (Math.round(angleinteger) + 2) % herorows; // Toast.makeText(this, String.valueOf(round), // Toast.LENGTH_LONG).show(); } } public class Sprite { Game game; private Bitmap bmp; public Sprite(Game game, Bitmap bmp) { // TODO Auto-generated constructor stub this.game = game; this.bmp = bmp; } } } Here is the LogCat if it helps.... 08-22 23:18:06.980: D/AndroidRuntime(28151): Shutting down VM 08-22 23:18:06.980: W/dalvikvm(28151): threadid=1: thread exiting with uncaught exception (group=0xb3f6f4f0) 08-22 23:18:06.980: D/AndroidRuntime(28151): procName from cmdline: com.example.killthemall 08-22 23:18:06.980: E/AndroidRuntime(28151): in writeCrashedAppName, pkgName :com.example.killthemall 08-22 23:18:06.980: D/AndroidRuntime(28151): file written successfully with content: com.example.killthemall StringBuffer : ;com.example.killthemall 08-22 23:18:06.990: I/Process(28151): Sending signal. PID: 28151 SIG: 9 08-22 23:18:06.990: E/AndroidRuntime(28151): FATAL EXCEPTION: main 08-22 23:18:06.990: E/AndroidRuntime(28151): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.killthemall/com.example.killthemall.Game}: java.lang.NullPointerException 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.os.Handler.dispatchMessage(Handler.java:99) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.os.Looper.loop(Looper.java:130) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread.main(ActivityThread.java:3683) 08-22 23:18:06.990: E/AndroidRuntime(28151): at java.lang.reflect.Method.invokeNative(Native Method) 08-22 23:18:06.990: E/AndroidRuntime(28151): at java.lang.reflect.Method.invoke(Method.java:507) 08-22 23:18:06.990: E/AndroidRuntime(28151): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) 08-22 23:18:06.990: E/AndroidRuntime(28151): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638) 08-22 23:18:06.990: E/AndroidRuntime(28151): at dalvik.system.NativeStart.main(Native Method) 08-22 23:18:06.990: E/AndroidRuntime(28151): Caused by: java.lang.NullPointerException 08-22 23:18:06.990: E/AndroidRuntime(28151): at com.example.killthemall.Game$KhogenView.<init>(Game.java:96) 08-22 23:18:06.990: E/AndroidRuntime(28151): at com.example.killthemall.Game.onCreate(Game.java:58) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 08-22 23:18:06.990: E/AndroidRuntime(28151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 08-22 23:18:06.990: E/AndroidRuntime(28151): ... 11 more 08-22 23:18:18.050: D/AndroidRuntime(28191): Shutting down VM 08-22 23:18:18.050: W/dalvikvm(28191): threadid=1: thread exiting with uncaught exception (group=0xb3f6f4f0) 08-22 23:18:18.050: I/Process(28191): Sending signal. PID: 28191 SIG: 9 08-22 23:18:18.050: D/AndroidRuntime(28191): procName from cmdline: com.example.killthemall 08-22 23:18:18.050: E/AndroidRuntime(28191): in writeCrashedAppName, pkgName :com.example.killthemall 08-22 23:18:18.050: D/AndroidRuntime(28191): file written successfully with content: com.example.killthemall StringBuffer : ;com.example.killthemall 08-22 23:18:18.050: E/AndroidRuntime(28191): FATAL EXCEPTION: main 08-22 23:18:18.050: E/AndroidRuntime(28191): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.killthemall/com.example.killthemall.Game}: java.lang.NullPointerException 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.os.Handler.dispatchMessage(Handler.java:99) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.os.Looper.loop(Looper.java:130) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread.main(ActivityThread.java:3683) 08-22 23:18:18.050: E/AndroidRuntime(28191): at java.lang.reflect.Method.invokeNative(Native Method) 08-22 23:18:18.050: E/AndroidRuntime(28191): at java.lang.reflect.Method.invoke(Method.java:507) 08-22 23:18:18.050: E/AndroidRuntime(28191): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) 08-22 23:18:18.050: E/AndroidRuntime(28191): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638) 08-22 23:18:18.050: E/AndroidRuntime(28191): at dalvik.system.NativeStart.main(Native Method) 08-22 23:18:18.050: E/AndroidRuntime(28191): Caused by: java.lang.NullPointerException 08-22 23:18:18.050: E/AndroidRuntime(28191): at com.example.killthemall.Game$KhogenView.<init>(Game.java:96) 08-22 23:18:18.050: E/AndroidRuntime(28191): at com.example.killthemall.Game.onCreate(Game.java:58) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 08-22 23:18:18.050: E/AndroidRuntime(28191): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 08-22 23:18:18.050: E/AndroidRuntime(28191): ... 11 more

    Read the article

  • Fatal Exception : AsyncTask #1

    - by Nadirah Ibtisam
    help help..huu Im having a problem here..seems there was no error in codes..but when I run it...and click button to view map consist routing the map..It appers to be close all of sudden..why is that? Please help me friends.. Im developing an app to read my current location and creating route to A position.. here are the codes: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); onNewIntent(getIntent()); Drawable marker = getResources().getDrawable(R.drawable.marker); Drawable marked_places = getResources().getDrawable(R.drawable.feringgi_map); mymap = (MapView)findViewById(R.id.mymap); controller = mymap.getController(); // extract MapView from layout mymap.getController().setZoom(15); mymap.setBuiltInZoomControls(true); mymap.setSatellite(false); // create an overlay that shows our current location myLocationOverlay = new MyLocationOverlay(this, mymap); // add this overlay to the MapView and refresh it mymap.getOverlays().add(myLocationOverlay); mymap.postInvalidate(); myLocationOverlay.runOnFirstFix(new Runnable() { @Override public void run() { controller.setZoom(10); controller.animateTo(myLocationOverlay.getMyLocation()); } }); zoomToMyLocation(); switch(selecteditem) { case 0: switch(selectedsubitem){ case 0://Place A locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location !=null) { loc=location; } GeoPoint destination = getPoint(3.144341, 101.69541800000002); new BackgroundTask(this, loc, destination).execute(); break; } } class BackgroundTask extends AsyncTask<Void, Void, Void> { private Location location; private GeoPoint dest; private Route route; private Activity activity; private ProgressDialog dialog; private RouteOverlay routeOverlay; public BackgroundTask(Activity activity, Location loc, GeoPoint dest) { location=loc; this.dest=dest; this.activity=activity; dialog = new ProgressDialog(activity); } @Override protected void onPreExecute() { dialog.setCancelable(false); dialog.setTitle("Loading..."); dialog.setMessage("Calculating Route..."); dialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { cancel(true); MyMap.this.finish(); }}); dialog.show(); } protected Void doInBackground(Void... params) { if(isNetworkAvailable()) { if(haveInternet()) { try{ route = directions(new GeoPoint((int)(location.getLatitude()*1.0E6),(int)(location.getLongitude()*1.0E6)), dest); } catch (NullPointerException e){ } } else { return null; } } else { return null; } return null; } And this is the log cat (updated).. : 12-10 12:21:15.527: E/AndroidRuntime(10146): FATAL EXCEPTION: AsyncTask #1 12-10 12:21:15.527: E/AndroidRuntime(10146): java.lang.RuntimeException: An error occured while executing doInBackground() 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$3.done(AsyncTask.java:278) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.lang.Thread.run(Thread.java:856) 12-10 12:21:15.527: E/AndroidRuntime(10146): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10228 nor current process has android.permission.ACCESS_NETWORK_STATE. 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.Parcel.readException(Parcel.java:1327) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.Parcel.readException(Parcel.java:1281) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:728) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:378) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.isNetworkAvailable(MyMap.java:488) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:411) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:1) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-10 12:21:15.527: E/AndroidRuntime(10146): ... 5 more This is my manifest file: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.madcatworld.testtesttest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <com.google.android.maps.MapView android:id="@+id/mymap" android:clickable="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="XXXX" /> <activity android:theme="@style/StyledIndicators" android:name=".MainTest" android:label="@string/title_activity_main" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps"/> <activity android:name="A" android:screenOrientation="portrait"></activity> <activity android:name="B" android:screenOrientation="portrait"></activity> <activity android:name="C" android:screenOrientation="portrait"></activity> </application> </manifest> For your information, I already put ACCESS_NETWORK_STATE in my manifest.. Can u discover what cause the error? No error in code..but it failed to review my route map..:( Thanks Friends

    Read the article

  • Desktop Notifications, aka Internal Alert System

    - by Refracted Paladin
    It has become apparent that where I work needs, internally, a "notification system". The issue being that we are very spread out throughout multiple buildings and the bulk of the work force regularly keeps there email closed for hours at a time. I need to create a simple way to be able to push out a message and have it "pop up" on everyones computer(or a single computer). My first thought was to write a windows service that calls a winform/wpf app that resides on each computer that simply pops up with the message. Not sure how viable an idea that is but this is just brain-storming. A different route, I thought, could be an app that resides in the systray on each computer that polls a db table and using the Query Notifications could pop up a message each time a new row is added. Then simply create an insanely basic app for writing a row to that table. So, what I am asking is if any one else has walked this path. If so, how? What things did you take into consideration? Are either of my ideas valid starting points or are "egg and my face in perfect alignment"? Is there a different way that is even simpler? Thanks

    Read the article

  • Adding an observer to UIImageView? observer & notifications

    - by sagar
    Each class has almost one method named addObserver [imgVURL addObserver:<#(NSObject *)observer#> forKeyPath:<#(NSString *)keyPath#> options:<#(NSKeyValueObservingOptions)options#> context:<#(void *)context#>] Here, imgVURL is an image which is going to be load an image asynchronously. When image will be loaded dynamically - other class will set an image from loaded data. Now, my question is how can we add an observer to UIImageView's instance. Observer and notifications are same or not ? If it is not then what's different ? Let's have some sample code That I did in my project to understand my question. // locating image view from Scroll view by it's tag imgVURL=(UIImageView*)[scrMain viewWithTag:(kTagImagesTag+i)]; // ImageViewURL is a class which contains methods of // didReceiveResponse // didReceiveData // connection ImageViewURL *tmp=[[ImageViewURL alloc] init]; // it has a nonatomic property which will take the reference of my image view tmp.imgV=imgVURL; // now I will pass a url from my an array to property strURL // in strUrl I have custom setter // in which I am initializing a connection tmp.strUrl=[NSURL URLWithString:[[tblmain objectAtIndex:i] valueForKey:@"url"]]; // from ImageViewURL.m file -(void)connectionDidFinishLoading:(NSURLConnection *)connection { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; // NSLog@"ImageView Ref From - %@",imgV); // see imgV has reference of my -> imgVURL (nonatomic,assign) imgV.image=[UIImage imageWithData:myWebData]; [connection release]; connection=nil; } // as you can see in above code many many images are loaded asynchronously // now How can I add an observer to an imageview whether it received or not.

    Read the article

  • Android threading and database locking

    - by Sena Gbeckor-Kove
    Hi, We are using AsyncTasks to access database tables and cursors. Unfortunately we are seeing occasional exceptions regarding the database being locked. E/SQLiteOpenHelper(15963): Couldn't open iviewnews.db for writing (will try read-only): E/SQLiteOpenHelper(15963): android.database.sqlite.SQLiteException: database is locked E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1637) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1587) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:659) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:652) E/SQLiteOpenHelper(15963): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:482) E/SQLiteOpenHelper(15963): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) E/SQLiteOpenHelper(15963): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158) E/SQLiteOpenHelper(15963): at com.iview.android.widget.IViewNewsTopStoryWidget.initData(IViewNewsTopStoryWidget.java:73) E/SQLiteOpenHelper(15963): at com.iview.android.widget.IViewNewsTopStoryWidget.updateNewsWidgets(IViewNewsTopStoryWidget.java:121) E/SQLiteOpenHelper(15963): at com.iview.android.async.GetNewsTask.doInBackground(GetNewsTask.java:338) E/SQLiteOpenHelper(15963): at com.iview.android.async.GetNewsTask.doInBackground(GetNewsTask.java:1) E/SQLiteOpenHelper(15963): at android.os.AsyncTask$2.call(AsyncTask.java:185) E/SQLiteOpenHelper(15963): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256) E/SQLiteOpenHelper(15963): at java.util.concurrent.FutureTask.run(FutureTask.java:122) E/SQLiteOpenHelper(15963): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648) E/SQLiteOpenHelper(15963): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673) E/SQLiteOpenHelper(15963): at java.lang.Thread.run(Thread.java:1060) Does anybody have a general example for code which writes to a database from a different thread than the one reading and how can we ensure thread safety. One suggestion I've had is to use a ContentProvider, as this would handle the access of the database from multiple threads. I am going to look at this, but is this the recommended method of handling such a problem? It seems rather heavyweight considering we're talking about in front or behind Thanks in advance.

    Read the article

  • Android Custom Adapter with Bar Progress

    - by xger86x
    Hi, i have a custom adapter for an arraylist. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <ProgressBar android:id="@+id/downloadprogress" style="?android:attr/progressBarStyleHorizontal" android:layout_width="200dip" android:layout_height="wrap_content" android:max="100" android:progress="50" android:secondaryProgress="75" /> <TextView android:id="@+id/tripsname" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> but when i try to access to the progress bar in the adapter private class MyAdapter extends ArrayAdapter<Trip> { int resource; public MyAdapter(Context context, int resource, ArrayList<Trip> items) { super(context, resource,items); this.resource=resource; } @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout tripListItemView; final Trip t = getItem(position); String name = t.getName(); boolean offline = t.isOffline() ; if(convertView==null) { tripListItemView = new LinearLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater)getContext().getSystemService(inflater); vi.inflate(resource, tripListItemView, true); } else { tripListItemView = (LinearLayout) convertView; } setProgressBarVisibility(true); View v = findViewById(R.id.downloadprogress); ProgressBar progressHorizontal = (ProgressBar) findViewById(R.id.downloadprogress); it always return null, like it doesn't find the progress bar. However, the progress bar is shown in the list, but i need to access to it inside the adapter. Anybody knows the solution? Thanks

    Read the article

  • Window Leaked on FBConnect in Android?

    - by Praveen Chandrasekaran
    how to rectify this Window Leaked Exception. i cant find why its occured. My LogCat Info: 05-07 17:25:05.402: ERROR/WindowManager(13595): Activity com.codecarpet.fbconnect.FBLoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@433b9ae0 that was originally added here 05-07 17:25:05.402: ERROR/WindowManager(13595): android.view.WindowLeaked: Activity com.codecarpet.fbconnect.FBLoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@433b9ae0 that was originally added here 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.view.ViewRoot.<init>(ViewRoot.java:214) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.view.Window$LocalWindowManager.addView(Window.java:409) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.app.Dialog.show(Dialog.java:238) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.app.ProgressDialog.show(ProgressDialog.java:107) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.app.ProgressDialog.show(ProgressDialog.java:95) 05-07 17:25:05.402: ERROR/WindowManager(13595): at com.codecarpet.fbconnect.FBProgressDialog.show(FBProgressDialog.java:106) 05-07 17:25:05.402: ERROR/WindowManager(13595): at com.codecarpet.fbconnect.FBDialog$WebViewClientImpl.onPageStarted(FBDialog.java:508) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:214) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.os.Handler.dispatchMessage(Handler.java:99) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.os.Looper.loop(Looper.java:123) 05-07 17:25:05.402: ERROR/WindowManager(13595): at android.app.ActivityThread.main(ActivityThread.java:4203) 05-07 17:25:05.402: ERROR/WindowManager(13595): at java.lang.reflect.Method.invokeNative(Native Method) 05-07 17:25:05.402: ERROR/WindowManager(13595): at java.lang.reflect.Method.invoke(Method.java:521) 05-07 17:25:05.402: ERROR/WindowManager(13595): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 05-07 17:25:05.402: ERROR/WindowManager(13595): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 05-07 17:25:05.402: ERROR/WindowManager(13595): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • How to Implement Custom List View for the list Items in Android Application

    - by avadhani
    I had a problem with the list view having both parent list and the child list of the list activity(implemented through database query). I wish to show them differing their properties by changing the text style (parent list items are in bold, child list items are in normal style). The following is the code from which all the child and parent list items having the same style(bold): String sql = "SELECT Parentid,Childid,Name from (select com.Parentid, com.Childid, com.Name from table1 mem inner join table2 cd on mem.column1=cd.column1 inner join table3 com on com.childid = mem.childid where Parentid is NULL UNION SELECT com.Parentid, com.Childid,com.Name from table1 mem inner join table3 com on com.childid = mem.childid inner join table2 cd on mem.column1=cd.column1 where Parentid is NOT NULL) a group by Parentid, Childid;"; Cursor cdata = myDbHelper.getView(sql); and the List Adapter is: private static final String fields[] = {"Name"}; int[] names = new int[] {R.id.name}; SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this,R.layout.clientlist1, cdata, fields,names ); and the clientlist.xml is: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/MainLayout" android:padding="5px"> <TextView android:id="@+id/name" android:layout_alignParentRight="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="12sp" android:textColor="#104082" android:textStyle="bold" android:layout_weight="1" /> From this i am getting the list having the complete list having both parent and child list items in a single list view. I wish to differ in their text style(bold, normal) for parent and child items respectively. Please help me with the code/links. Thanks a lot in advance.

    Read the article

  • ListView in Android, handler for clicking item

    - by eljainc
    Hello, I have an activity in Android which uses a ListView. When I click on an item in the ListView, I would like to be able to determine which item was clicked. I have the following code: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.listr); //setupDB(); // populateList3(); ListView lv = (ListView) findViewById(R.id.ListView01); lv.setClickable(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(ListRecords.this,"Clicked!", Toast.LENGTH_LONG).show(); } }); } My XML code: xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Linear03lr" android:layout_width="fill_parent" android:orientation="vertical" android:gravity="center" android:layout_height="fill_parent"> android:layout_width="wrap_content" android:layout_height="400dp" / <Button android:id="@+id/previousbutton" android:gravity="center_horizontal" android:layout_width = "fill_parent" android:layout_height = "fill_parent" android:text="Previous Menu"/> </LinearLayout> What am I missing here to be able to intercept clicks on the Listview? Thanks

    Read the article

  • Why is android:transcriptMode="normal" not working properly?

    - by BCS
    I've been doing a lot of fiddling with an issue I've been having. What happens is each time an item gets added to my listview (adapter) I expect it to auto-scroll if I'm at the last item (which it will do to an extent); HOWEVER, if 3 or more items get added at once, it will not auto-scroll. Here is the XML of that listview: <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:transcriptMode="normal"/> I tried a workaround using a snippet I found here. My code is as follows: public void addChat(final String text, final String username) { this.runOnUiThread(new Runnable() { public void run() { globals.chatAdapter.add(DateFormat.format("hh:mmaa", Calendar.getInstance()).toString(), username, text); globals.chatAdapter.notifyDataSetChanged(); int lastP = getListView().getLastVisiblePosition(); int count = globals.chatAdapter.getCount() - 1; if (lastP == globals.chatAdapter.oldP || lastP == -1) { getListView().setSelection(count); } globals.chatAdapter.oldP = count; } }); } The problem with this is when a bunch of items come in at once, getListView().getLastVisiblePosition() will not update right away causing a setSelection() to never get called, and thus no auto-scroll. Any suggestions?

    Read the article

  • text view not wrapping

    - by leenolasco
    I just tried a sample of retrieving and passing it to a textview. I am having some trouble wrapping my textview. The bottom part is not completely shown. What do i need to add to the xml file for it to completely show the bottom part of the data? <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="left" android:orientation="vertical" android:padding="5dp" > <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" > <TextView android:id="@+id/tvFA" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="36dp" android:layout_marginTop="36dp" android:text="TextView" android:maxLines = "1000" android:scrollbars = "vertical" android:textSize="20sp" /> </ScrollView> </RelativeLayout>

    Read the article

  • Video playback on VideoView disappears after going back from another Activity

    - by pixel
    I have two Activities: one with VideoView and the second one. I start watching a video in the first Activity, then during playback I start second Activity. After going back to first Activity I can hear sound but see no picture. My Video 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"> <VideoView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/videoView" android:layout_gravity="center" /> <ListView android:layout_width="fill_parent" android:layout_height="125dp" android:id="@+id/ListView" /> </LinearLayout> Do you have any ideas why video doesn't appear?

    Read the article

  • Activity triggered by a click on a Notification

    - by Zelig63
    From a Service, I trigger a Notification which, when clicked, has to launch an Activity. To do this, I use the following code : notification=new Notification(icone,title,System.currentTimeMillis()); intent=new Intent(getApplicationContext(),myActivity.class); intent.putExtra("org.mypackage.name",true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pendingIntent=PendingIntent.getActivity(getApplicationContext(),0,intent,PendingIntent.FLAG_ONE_SHOT); notification.setLatestEventInfo(getApplicationContext(),title,"Message",pendingIntent); notification.flags|=Notification.FLAG_AUTO_CANCEL; ((NotificationManager)contexte.getSystemService(Context.NOTIFICATION_SERVICE)).notify("label,0,notification); When I click on the Notification, the Activity is correctly launched. But it's Intent doesn't contain the extra boolean added with the line intent.putExtra("org.mypackage.name",true);. Does anyone have an idea of this behaviour? I can add that I use Android 4. Thanks in advance for the time you will spend trying to help me.

    Read the article

  • The admob ads not dispaly, but no error in my logcat

    - by ???
    package com.admob.test; import android.app.Activity; import android.os.Bundle; public class AdmobTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.admob.test" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="4" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".AdmobTestActivity" 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="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|s mallestScreenSize" /> </application> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> </manifest> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="xxxxxxxxxxxxxxx" ads:adSize="BANNER" ads:testDevices="C904358AFB272CDFA888A5C1CB914DA4" ads:loadAdOnCreate="true"/> </LinearLayout> I'd like to test my admob ads in my Android application, but the ads can't display. And no error can be found in the logcat. I also can find the success request for ads from Admob. I use "X" to indicate my publish id, could any expert kindly help me? thanks in advanse.

    Read the article

  • Pop-Up Window at inital start up, of android application

    - by Josh Fairbank
    I am trying to find a code that will do a popup at the initial start up on an installed app. Much like a changelog that is starting to appear in more and more apps. I have found some similar codes, but being a beginner I haven't been able to figure out where to exactly put the code in and I always have tons of errors that still do not work once I try and fix them. I am working in Eclipse with an android project, and I'm using a webview to show a website. XML: <?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"> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_height="fill_parent" android:layout_width="fill_parent" android:scrollbarAlwaysDrawVerticalTrack="false"/> </LinearLayout> Java File: package com.A2Ddesigners.WhatThe; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient; import android.view.KeyEvent; public class Whatthe extends Activity { WebView webview; /** Called when the activity is first created. */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { webview.goBack(); return true; } return super.onKeyDown(keyCode, event); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webview = (WebView) findViewById(R.id.webview); webview.setWebViewClient(new HelloWebViewClient()); webview.getSettings().setJavaScriptEnabled(true); webview.setInitialScale(50); webview.getSettings().setUseWideViewPort(true); webview.loadUrl("http://mdsitest2.com/"); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } }

    Read the article

  • using AsyncTask class for parallel operationand displaying a progress bar

    - by Kumar
    I am displaying a progress bar using Async task class and simulatneously in parallel operation , i want to retrieve a string array from a function of another class that takes some time to return the string array. The problem is that when i place the function call in doing backgroung function of AsyncTask class , it gives an error in Doing Background and gives the message as cant change the UI in doing Background .. Therefore , i placed the function call in post Execute method of Asynctask class . It doesnot give an error but after the progress bar has reached 100% , then the screen goes black and takes some time to start the new activity. How can i display the progress bar and make the function call simultaneously.??plz help , m in distress here is the code package com.integrated.mpr; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class Progess extends Activity implements OnClickListener{ static String[] display = new String[Choose.n]; Button bprogress; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.progress); bprogress = (Button) findViewById(R.id.bProgress); bprogress.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case R.id.bProgress: String x ="abc"; new loadSomeStuff().execute(x); break; } } public class loadSomeStuff extends AsyncTask<String , Integer , String>{ ProgressDialog dialog; protected void onPreExecute(){ dialog = new ProgressDialog(Progess.this); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMax(100); dialog.show(); } @Override protected String doInBackground(String... arg0) { // TODO Auto-generated method stub for(int i = 0 ;i<40;i++){ publishProgress(5); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } dialog.dismiss(); String y ="abc"; return y; } protected void onProgressUpdate(Integer...progress){ dialog.incrementProgressBy(progress[0]); } protected void onPostExecute(String result){ display = new Logic().finaldata(); Intent openList = new Intent("com.integrated.mpr.SENSITIVELIST"); startActivity(openList); } } }

    Read the article

  • Buttons with equal heights.

    - by Rpond
    Linear layout below. This layout is aligned parent bottom in a Relative Layout. Problem is I want all buttons to have the same height. I have tried layout_gravity="fill" but that doesn't seem to work. <LinearLayout android:id="@+id/button_layout" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="#FFFFFF" android:layout_alignParentBottom="true"> <Button android:text="Send" android:id="@+id/send_button" android:layout_weight="1" android:layout_gravity="fill" android:layout_width="0dip" android:layout_height="wrap_content"> </Button> <Button android:text="Report Missing Image" android:id="@+id/report_button" android:layout_weight="1" android:layout_width="0dip" android:layout_height="wrap_content"> </Button> <Button android:text="Close" android:id="@+id/close_button" android:layout_weight="1" android:layout_gravity="fill" android:layout_width="0dip" android:layout_height="wrap_content"> </Button> </LinearLayout>

    Read the article

  • Android ListView in Activity

    - by Dev.Android
    My layout is like this Title Layout Listview BottomLayout. I have an 150 item which i have custom layout which i want to add in listview. So my main problem is i want to add slowly slowly one by one that customlayouts in listview. So whenever the first screen is displayed i want load 10 items from server and add it to listview.then onscroll down i want to load the remaining 10 items from 150 cutom layouts. So how can I do this activity?

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >