Search Results

Search found 12222 results on 489 pages for 'initial context'.

Page 131/489 | < Previous Page | 127 128 129 130 131 132 133 134 135 136 137 138  | Next Page >

  • How to control overlapping Alpha fades on iPhone...

    - by ReduxDJ
    I have two animation methods, basically the just repeat... How do I prevent them from overlapping and flickering, is there a convenient way to do this? Thanks, -(void) doPowerChangeAnimUp { powerIconChange .alpha = 0; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:)]; [UIView setAnimationDelegate:self] ; [UIView setAnimationDuration:2]; [powerIconChange setAlpha:1]; [UIView commitAnimations]; } -(void)animationDidStop:(NSString *)animationID { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self] ; [UIView setAnimationDidStopSelector:@selector(doPowerChangeAnimUp)]; [UIView setAnimationDuration:2]; [powerIconChange setAlpha:0]; [UIView commitAnimations]; }

    Read the article

  • Inject a EJB into a JSF converter with JEE6

    - by Michael Bavin
    Hi, I have a stateless EJB that acceses my database. I need this bean in a JSF 2 converter to retreive an entity object from the String value parameter. I'm using JEE6 with Glassfish V3 @EJB annotation does not work and gets a NPE, because it's in the faces context and it has not access to the ejb context. My question is: Is it still possible to Inject this bean (With a @Resource or other annotation, a JNDI lookup,...), or do i need a workaround? Thank you Solution Do a JNDI lookup like this: try { ic = new InitialContext(); myejb= (MyEJB) ic .lookup("java:global/xxxx/MyEJB"); } catch (NamingException e) { e.printStackTrace(); }

    Read the article

  • Regular Expression to isolate an html tag

    - by orit cohen
    I'm looking for a regular expression to isolate an html tag. This includes the TAG the ATTRIBUTES and the CONTNET inside. Let's say I have this: <html> <body> aajsdfkjaskd <TAGNAME name="bla" context="non">hfdfhdj </TAGNAME> </body> </html> I need a regular expression that would return: <TAGNAME name="bla" context="non">hfdfhdj </TAGNAME> Thank, Joe

    Read the article

  • Id property not populated

    - by fingers
    I have an identity mapping like so: Id(x => x.GuidId).Column("GuidId") .GeneratedBy.GuidComb().UnsavedValue(Guid.Empty); When I retrieve an object from the database, the GuidId property of my object is Guid.Empty, not the actual Guid (the property in the class is of type System.Guid). However, all of the other properties in the object are populated just fine. The database field's data type (SQL Server 2005) is uniqueidentifier, and marked as RowGuid. The application that is connecting to the database is a VB.NET Web Site project (not a "Web Application" or "MVC Web Application" - just a regular "Web Site" project). I open the NHibernate session through a custom HttpModule. Here is the HttpModule: public class NHibernateModule : System.Web.IHttpModule { public static ISessionFactory SessionFactory; public static ISession Session; private static FluentConfiguration Configuration; static NHibernateModule() { if (Configuration == null) { string connectionString = cfg.ConfigurationManager.ConnectionStrings["myDatabase"].ConnectionString; Configuration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(cs => cs.Is(connectionString))) .ExposeConfiguration(c => c.Properties.Add("current_session_context_class", "web")) .Mappings(x => x.FluentMappings.AddFromAssemblyOf<LeadMap>().ExportTo("C:\\Mappings")); } SessionFactory = Configuration.BuildSessionFactory(); } public void Init(HttpApplication context) { context.BeginRequest += delegate { Session = SessionFactory.OpenSession(); CurrentSessionContext.Bind(Session); }; context.EndRequest += delegate { CurrentSessionContext.Unbind(SessionFactory); }; } public void Dispose() { Session.Dispose(); } } The strangest part of all, is that from my unit test project, the GuidId property is returned as I would expect. I even rigged it to go for the exact row in the exact database as the web site was hitting. The only differences I can think of between the two projects are The unit test project is in C# Something with the way the session is managed between the HttpModule and my unit tests The configuration for the unit tests is as follows: Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(cs => cs.Is(connectionString))) .Mappings(x => x.FluentMappings.AddFromAssemblyOf<LeadDetailMap>()); I am fresh out of ideas. Any help would be greatly appreciated. Thanks

    Read the article

  • How to declare a warning on field with AspectJ

    - by Ralph
    I want to declare a warning on all fields Annotated with @org.jboss.weld.context.ejb.Ejb in AspectJ. But I do not find a way how to select that field. I guess the aspect should be something like that: public aspect WrongEjbAnnotationWarningAspect { declare warning : within(com.queomedia..*) && ??? (@org.jboss.weld.context.ejb.Ejb) : "WrongEjbAnnotationErrorAspect: use javax.ejb.EJB instead of weld Ejb!"; } Or is it impossible to declare warnings on fields at all?

    Read the article

  • webservice doesn't get called by jQuery

    - by aspdotnetuser
    Hi, I want to call a webservice using jQuery.ajax() but the webervice doesn't get called. - If I change the url: to reference a .ashz file it gets called but not .asmx? Here's the code I'm using: jQuery.ajax({ type: "POST", url: "/services/CheckUsername.asmx/CheckUsername", // this doesn't get called //url: "/services/CheckUsername.ashx/ProcessRequest", this gets called data: '{ "context": "' + "username" + '"}', contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (msg) { alert("Result: " + msg); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("Error: " + textStatus) } The .ashz file gets called but a parsererror is retuned because it's returning http context - how can I modify this to get a string return type from a webservice? Thanks,

    Read the article

  • hadoop mapper static initialisation

    - by rakeshr
    Hi, I have a code fragment in which I am using a static code block to initialize a variable. public static class JoinMap extends Mapper<IntWritable, MbrWritable, LongWritable, IntWritable> { ....... public static RTree rt = null; static { String rtreeFileName = "R.rtree"; rt = new RTree(rtreeFileName); } public void map(IntWritable key, MbrWritable mbr,Context context) throws IOException, InterruptedException { ......... List elements = rt.overlaps(mbr.getRect()); ....... } } My problem is that the variable rt in the above code fragment is not getting initialised. Can anybody suggest a fix or an alternate way to initialise the variable. I don't want to initialise it inside my map function since that slows down the entire process.

    Read the article

  • File created using MODE_WORLD_READABLE not getting sent as attachment by email

    - by Dheeraj
    I created the SQLite DB using the following code: context.openOrCreateDatabase(dbName, Context.MODE_WORLD_READABLE, null); And tried to send it as attachment by email using the following code: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND) .setType("message/rfc822") .putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(getDatabasePath(dbName))); startActivity(Intent.createChooser(emailIntent, null)); This opens the GMail compose activity with the attachment icon. But the recipient did not receive the attachment. This has been asked before. But it looks like there is no solution other than to copy the db file to SD card. My question then is: What is the use of the MODE_WORLD_READABLE flag if another app like GMail is unable to read the file?

    Read the article

  • JAXB doesn't unmarshal list of interfaces

    - by Joker_vD
    It seems JAXB can't read what it writes. Consider the following code: interface IFoo { void jump(); } @XmlRootElement class Bar implements IFoo { @XmlElement public String y; public Bar() { y = ""; } public Bar(String y) { this.y = y; } @Override public void jump() { System.out.println(y); } } @XmlRootElement class Baz implements IFoo { @XmlElement public int x; public Baz() { x = 0; } public Baz(int x) { this.x = x; } @Override public void jump() { System.out.println(x); } } @XmlRootElement public class Holder { private List<IFoo> things; public Holder() { things = new ArrayList<>(); } @XmlElementWrapper @XmlAnyElement public List<IFoo> getThings() { return things; } public void addThing(IFoo thing) { things.add(thing); } } // ... try { JAXBContext context = JAXBContext.newInstance(Holder.class, Bar.class, Baz.class); Holder holder = new Holder(); holder.addThing(new Bar("1")); holder.addThing(new Baz(2)); holder.addThing(new Baz(3)); for (IFoo thing : holder.getThings()) { thing.jump(); } StringWriter s = new StringWriter(); context.createMarshaller().marshal(holder, s); String data = s.toString(); System.out.println(data); StringReader t = new StringReader(data); Holder holder2 = (Holder)context.createUnmarshaller().unmarshal(t); for (IFoo thing : holder2.getThings()) { thing.jump(); } } catch (Exception e) { System.err.println(e.getMessage()); } It's a simplified example, of course. The point is that I have to store two very differently implemented classes, Bar and Baz, in one collection. Well, I observed that they have pretty similar public interface, so I created an interface IFoo and made them two to implement it. Now, I want to have tools to save and load this collection to/from XML. Unfortunately, this code doesn't quite work: the collection is saved, but then it cannot be loaded! The intended output is 1 2 3 some xml 1 2 3 But unfortunately, the actual output is 1 2 3 some xml com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to testapplication1.IFoo Apparently, I need to use the annotations in a different way? Or to give up on JAXB and look for something else? I, well, can write "XMLNode toXML()" method for all classes I wan't to (de)marshal, but...

    Read the article

  • How do I create an image for a UITableViewCell dynamically

    - by Xetius
    I want to dynamically create an image for a UITableViewCell which is basically a square with a number in it. The square has to be a colour (specified dynamically) and contains a number as text inside it. I have looked at the CGContextRef documentation, but can't seem to work out how to get the image to fill with a specified certain colour. This is what I have been trying so far. -(UIImage*)createCellImageWithCount:(NSInteger)cellCount AndColour:(UIColor*)cellColour { CGFloat height = IMAGE_HEIGHT; CGFloat width = IMAGE_WIDTH; UIImage* inputImage; UIGraphicsBeginImageContext(CGSizeMake(width, height)); CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); // drawing code goes here // But I have no idea what. UIGraphicsPopContext(); UIImage* outputImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return outImage; }

    Read the article

  • Entity update from ASP.NET MVC page with post to Edit action

    - by mare
    I have a form that posts back to /Edit/ and my action in controller looks like this: // // POST: /Client/Edit [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Client client) My form includes a subset of Client entity properties and I also include a hidden field that holds an ID of the client. The client entity itself is provided via the GET Edit action. Now I want to do entity update but so far I've only been trying without first loading the entity from the DB. Because the client object that comes in POST Edit has everything it needs. I want to update just those properties on the entity in datastore. So far I've tried with Context.Refresh() and AttachTo() but with no success - I'm getting all sorts of exceptions. I inspected the entity object as it comes from the web form and it looks fine (it does have an ID and entered data) mapped just fine. If I do it with Context.SaveChanges() then it just inserts new row..

    Read the article

  • how to create popup panel in mozilla firefox?

    - by user495688
    hello all.. i want to ask something about popup .. how to create popup panel in my addons to show text when users click context menu? the popup panel will execute javascript function inlinetrans.process() to show the result of inlinetrans process. this is my code to show context menu : <popup id="contentAreaContextMenu"> <menuseparator /> <menuitem id="inlinetransContextMenuPage" label="Terjemahkan dengan inlinetrans" image="chrome://inlinetrans/skin/imagesOn.png" class="menuitem-iconic" hidden="false" onclick="inlinetrans.process();"/> </popup> i want to create pop up like this http://abcdefu.wordpress.com/2008/07/25/writing-beautiful-ui-with-xul/ i don't need text box but i need to display my result of translation, what should i do? thank you for helping me..:)

    Read the article

  • delete data using entity framework

    - by user3474542
    The objective of the method below is to delete the data from the database using entity framework. I am populating the subscriptions entity by passing two parameters and then calling the atttach and remove method of the context class. Bureau entities is the context class. using (BUREAUEntities bureauEntities = new BUREAUEntities()) { var subscription = new SubcriptionRepository().GetSusbcriptionBySubscriptionTypeId(subscriptionTypeId, companyId); bureauEntities.Subscriptions.Attach((DataAccessLayer.DatabaseModel.Subscription)subscription); bureauEntities.Subscriptions.Remove(subscription); bureauEntities.SaveChanges(); } I am getting the following error message at An entity object cannot be referenced by multiple instances of IEntityChangeTracker at line bureauEntities.Subscriptions.Attach((DataAccessLayer.DatabaseModel.Subscription)subscription); Could somebody tell me where am I going wrong ?

    Read the article

  • Symfony 2 - UrlGenerator::doGenerate is called before listener

    - by guyaloni
    I want to add to the context a parameter, so when login is called I can use it in the route (similar to _locale). I can add this piece of code in HttpUtils.php (as resetLocale), but i don't find it very clean. The reason I need it is the firewall redirection to the login controller, which I would like to have in its route a customized parameter. My problem is that my listener is called after UrlGenerator::doGenerate is called, so I get a MissingMandatoryParametersException. Here is my config.yml relevant code: services: mycompany.demobundle.listener.request: class: MyCompany\DemoBundle\RequestListener arguments: [@router, @security.context] tags: - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } Any idea???

    Read the article

  • Call REST service while impersonating a user that is already authorized to the glasfish server

    - by user1894489
    There are two web-applications deployed on a glassfish server. Both web applications provide a REST web service. the access to both web-services is secured via glassfish security constraints (at the moment BASIC Auth and file-realm). Let's say a user is accessing the service of web application A. After he is authorized, service A wants to call service B via REST client. Is there a way for a service to impersonate a user that is already authorized to the glasfish server? Maybe something like forwarding the security context or editing the headers? Is there another Filter? @Context private SecurityContext securityContext; username = securityContext.getUserPrincipal().getName(); password = ??? client.addFilter(new com.sun.jersey.api.client.filter.HTTPBasicAuthFilter(username, password)); Thanks!

    Read the article

  • How can I write a file on an sftp-server with PHP?

    - by Daniel
    Hi, I hope someone here could help me, because I couldn't find any solution with Google. What I have to do is to generate a XML-string (that works) an save that directly into a file on an sftp-server. So far, so good... I used the following code with ftp and it works to, but not with ftps. So I either need another options-configuration for the stream or a different way to solve that task. Here my current code: $host = 'ftp.example.com'; $port = 22; $user = 'xxxxxx'; $pass = 'xxxxxx'; $file = 'test_' . time() . '.txt'; $ftpPath = sprintf('ftp://%s:%s@%s:%d/%s', $user, $pass, $host, $port, $file); $context = stream_context_create(array('ftp' = array('overwrite' = true))); file_put_contents($ftpPath, 'test', 0, $context);

    Read the article

  • No view for id for fragment

    - by guillaume
    I'm trying to use le lib SlidingMenu in my app but i'm having some problems. I'm getting this error: 11-04 15:50:46.225: E/FragmentManager(21112): No view found for id 0x7f040009 (com.myapp:id/menu_frame) for fragment SampleListFragment{413805f0 #0 id=0x7f040009} BaseActivity.java package com.myapp; import android.support.v4.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.Menu; import android.view.MenuItem; import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity; public class BaseActivity extends SlidingFragmentActivity { private int mTitleRes; protected ListFragment mFrag; public BaseActivity(int titleRes) { mTitleRes = titleRes; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(mTitleRes); // set the Behind View setBehindContentView(R.layout.menu_frame); if (savedInstanceState == null) { FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); mFrag = new SampleListFragment(); t.replace(R.id.menu_frame, mFrag); t.commit(); } else { mFrag = (ListFragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame); } // customize the SlidingMenu SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setMode(SlidingMenu.LEFT); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width); slidingMenu.setShadowDrawable(R.drawable.slidingmenu_shadow); slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); slidingMenu.setFadeDegree(0.35f); slidingMenu.setMenu(R.layout.slidingmenu); getActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: toggle(); return true; } return super.onOptionsItemSelected(item); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } } menu.xml <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:name="com.myapp.SampleListFragment" android:layout_width="match_parent" android:layout_height="match_parent" > </fragment> menu_frame.xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> SampleListFragment.java package com.myapp; import android.content.Context; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class SampleListFragment extends ListFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.list, null); } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); SampleAdapter adapter = new SampleAdapter(getActivity()); for (int i = 0; i < 20; i++) { adapter.add(new SampleItem("Sample List", android.R.drawable.ic_menu_search)); } setListAdapter(adapter); } private class SampleItem { public String tag; public int iconRes; public SampleItem(String tag, int iconRes) { this.tag = tag; this.iconRes = iconRes; } } public class SampleAdapter extends ArrayAdapter<SampleItem> { public SampleAdapter(Context context) { super(context, 0); } public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, null); } ImageView icon = (ImageView) convertView.findViewById(R.id.row_icon); icon.setImageResource(getItem(position).iconRes); TextView title = (TextView) convertView.findViewById(R.id.row_title); title.setText(getItem(position).tag); return convertView; } } } MainActivity.java package com.myapp; import java.util.ArrayList; import beans.Tweet; import database.DatabaseHelper; import adapters.TweetListViewAdapter; import android.os.Bundle; import android.widget.ListView; public class MainActivity extends BaseActivity { public MainActivity(){ super(R.string.app_name); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview_tweets); DatabaseHelper db = new DatabaseHelper(this); ArrayList<Tweet> tweets = db.getAllTweets(); TweetListViewAdapter adapter = new TweetListViewAdapter(this, R.layout.listview_item_row, tweets); listview.setAdapter(adapter); setSlidingActionBarEnabled(false); } } I don't understand why the view menu_frame is not found because I have a view with the id menu_frame and this view is a child of the layout menu_frame.

    Read the article

  • UILabels text disappears when animating

    - by Wilhelm Michaelsen
    I have this code: - (void)my_button_tapped { if (my_button.tag == 0) { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; my_label.frame = CGRectMake(450, 455, 200, 20); [UIView commitAnimations]; [my_button setBackgroundImage:[UIImage imageNamed:@"check.png"] forState:UIControlStateNormal]; my_button.tag = 1; } else { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; my_label.frame = CGRectMake(450, 455, 0, 20); [UIView commitAnimations]; [my_button setBackgroundImage:nil forState:UIControlStateNormal]; my_button.tag = 0; } } When I tap my_button first time the label is expanded into 200px width, when I press the button again the label decreases to 0px width but immediately at button press the text disappears. What's wrong?

    Read the article

  • iphone app store rss failed to open

    - by suvendu
    I write this, $opts = array( 'http' = array( 'user_agent' = 'PHP libxml agent', ) ); $context = stream_context_create($opts); libxml_set_streams_context($context); $doc = new DOMDocument(); $doc-load("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/limit=25/xml"); foreach ($doc-getElementsByTagName('item') as $node) { $title = $node-getElementsByTagName('title')-item(0)-nodeValue; $desc = $node-getElementsByTagName('description')-item(0)-nodeValue; $link = $node-getElementsByTagName('link')-item(0)-nodeValue; $date = $node-getElementsByTagName('pubDate')-item(0)-nodeValue; echo $title; echo '<br>'; echo $desc; } ?

    Read the article

  • Loop and ListView

    - by monomi
    I find a match with Regexp. How to correctly organize a loop, if more than one match and write it in the ListView? listAlbums = (ListView)findViewById(R.id.listAlbums); ... Pattern patternNameToId = Pattern.compile(kRegexp); String nameTo = "" Matcher matcherName = patternNameToId.matcher(response); if (matcherName.find()) { nameTo = matcherTopicTitle.group(2); albumsList = new ArrayList<String>(); albumsList.add(nameTo); ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, albumsList); listAlbums.setAdapter(adapter); } else Toast.makeText(context, "?? ???????", Toast.LENGTH_LONG).show();

    Read the article

  • What's wrong with this addProximity code?

    - by Pentium10
    I have this code: private void setupProximity() { Intent intent = new Intent(this, viewContacts.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0); LocationUtils.addProximity(this, -37.40, 144.55, 1000, 1000000, sender); } public static void addProximity(Context ctx,double lat, double lon, float rad,long exp, PendingIntent pintent) { LocationManager lm = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); lm.addProximityAlert(lat, lon, rad, exp, pintent); } Why I don't get the class to fire up? I am in the range of the zone.

    Read the article

  • Which application server should i choose for my project ?

    - by Dimitri
    Hi folks, I am currently developing an application for some researchers in my university.It's a small java program that you can use by command line. The next step is to package that program and deploy it to an application server. Some clients program will submit requests to the server who will call the tool that I wrote. Lately, we will add more tools to the server and he has to dispatch the requests to the right tool. Which application server fits my needs ? I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application. Is it possible to use those servers in some context different from web context? Which package archive should i use (jar, war) ? Any advice?

    Read the article

  • [Android] Show default selection color for custom listview

    - by Diego
    Hello, I have a listview with a custom BaseAdapter. Each row of the listview has a TextView and a CheckBox. The problem is when I click (or touch) any row, the textview foreground becomes gray, instead of the default behavior (background - green, textview foreground - white). Here is the code: row.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/layout"> <TextView android:id="@+id/main_lv_item_textView" style="@style/textViewBig" android:layout_alignParentLeft="true"/> <CheckBox android:id="@+id/main_lv_item_checkBox" style="@style/checkBox" android:layout_width="wrap_content" android:layout_alignParentRight="true"/> </RelativeLayout> Custom Adapter: public class CustomAdapter extends BaseAdapter { private List<Profile> profiles; private LayoutInflater inflater; private TextView tvName; private CheckBox cbEnabled; public CustomAdapter(List<Profile> profiles) { this.profiles = profiles; inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { return profiles.size(); } public Object getItem(int position) { return profiles.get(position); } public long getItemId(int position) { return position; } public View getView(final int position, View convertView, ViewGroup parent) { View row = inflater.inflate(R.layout.main_lv_item, null); final Profile profile = profiles.get(position); tvName = (TextView) row.findViewById(R.id.main_lv_item_textView); registerForContextMenu(tvName); cbEnabled = (CheckBox) row.findViewById(R.id.main_lv_item_checkBox); tvName.setText(profile.getName()); if (profile.isEnabled()) { cbEnabled.setChecked(true); } tvName.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putString(PROFILE_NAME_KEY, profile.getName()); Intent intent = new Intent(context, GuiProfile.class); intent.putExtras(bundle); startActivity(intent); } }); tvName.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { selectedProfileName = ((TextView) v).getText().toString(); return false; } }); cbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!profile.isEnabled()) { for (Profile profile : profiles) { if (profile.isEnabled()) { profile.setEnabled(false); Database.getInstance().storeProfile(profile); } } } profile.setEnabled(isChecked); Database.getInstance().storeProfile(profile); updateListView(); } }); return row; } } Any help would be appreciated.

    Read the article

< Previous Page | 127 128 129 130 131 132 133 134 135 136 137 138  | Next Page >