Search Results

Search found 8286 results on 332 pages for 'defined'.

Page 23/332 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • How to open new view (call an activity) from options menu defined in XML? (android)

    - by Portablejim
    I cant seem to open a new view from an options menu item. The program keeps crashing as it applies the intent and listener to the item. I am just beginning, so please be nice. The current view is mnfsms, and the view I am trying to open is mnfsms_settings. I am developing for 1.5. Could someone please help me get the menu working. The menu (called options_menu.xml): <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/settings_button" android:title="Settings" android:icon="@android:drawable/ic_menu_preferences" /> <item android:id="@+id/about_button" android:title="About" android:icon="@android:drawable/ic_menu_myplaces" /> </menu> The main view (called mnfsms.java): package com.example.mnfsms; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class mnfsms extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* OnClickListener myocl = new View.OnClickListener() { public void onClick(View v){ Intent myi = new Intent(mnfsms.this, mnfsms_settings.class); startActivity(myi); } };*/ } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); MenuItem mi_settings = (MenuItem)findViewById(R.id.settings_button); mi_settings.setIntent(new Intent(this, mnfsms_settings.class)); return true; } } The manifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mnfsms" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".mnfsms" android:label="@string/main_window_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".mnfsms_settings" android:label="string/main_window_name"> </activity> </application> <uses-sdk android:minSdkVersion="3" /> </manifest> The stacktrace: 01-06 15:07:58.045: ERROR/AndroidRuntime(2123): Uncaught handler: thread main exiting due to uncaught exception 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): java.lang.NullPointerException 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.example.mnfsms.mnfsms.onCreateOptionsMenu(mnfsms.java:30) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.app.Activity.onCreatePanelMenu(Activity.java:2038) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:421) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:664) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1278) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1735) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2188) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2158) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.handleMessage(ViewRoot.java:1490) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.os.Handler.dispatchMessage(Handler.java:99) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.os.Looper.loop(Looper.java:123) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.app.ActivityThread.main(ActivityThread.java:3948) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at java.lang.reflect.Method.invokeNative(Native Method) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at java.lang.reflect.Method.invoke(Method.java:521) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Why can a struct defined inside a function not be used as functor to std::for_each?

    - by Oswald
    The following code won't compile. The compiler complains about *no matching function for call to for_each*. Why is this so? #include <map> #include <algorithm> struct Element { void flip() {} }; void flip_all(std::map<Element*, Element*> input) { struct FlipFunctor { void operator() (std::pair<Element* const, Element*>& item) { item.second->flip(); } }; std::for_each(input.begin(), input.end(), FlipFunctor()); } When I move struct FlipFunctor before function flip_all, the code compiles. Full error message: no matching function for call to ‘for_each(std::_Rb_tree_iterator<std::pair<Element* const, Element*> >, std::_Rb_tree_iterator<std::pair<Element* const, Element*> >, flip_all(std::map<Element*, Element*, std::less<Element*>, std::allocator<std::pair<Element* const, Element*> > >)::FlipFunctor)’

    Read the article

  • How to use a defined struct from another source file?

    - by sasayins
    Hi, I am using Linux as my programming platform and C language as my programming language. My problem is, I define a structure in my main source file( main.c): struct test_st { int state; int status; }; So I want this structure to use in my other source file(e.g. othersrc.). Is it possible to use this structure in another source file without putting this structure in a header? Thanks

    Read the article

  • Can T-SQL function return user-defined table type?

    - by abatishchev
    I have my own type: CREATE TYPE MyType AS TABLE ( foo INT ) and a function receiving it as a parameter: CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return MyType AS ... can it return MyType or only TABLE repeating MyType's structure: CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return TABLE (foo INT) AS ... ?

    Read the article

  • How do you make a CSS-defined table-cell scroll?

    - by Giffyguy
    I want to be able to set the height of the table, and force the cells to scroll individually if they are larger than the table. Consider the following code: (see it in action here) <div style="display: table; position: absolute; width: 25%; height: 80%; min-height: 80%; max-height: 80%; left: 0%; top: 10%; right: 75%; bottom: 10%; border: solid 1px black;"> <div style="display: table-row;"> <div style="display: table-cell; border: solid 1px blue;"> {Some dynamic text content}<br/> This cell should shrink to fit it's contents. </div> </div> <div style="display: table-row;"> <div style="display: table-cell; border: solid 1px red; overflow: scroll;"> This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. </div> </div> </div> If you open this code (in IE8, in my case) you'll notice that the second cell fits in the table nicely when the browser is maximized. In theory, when you shrink the browser (forcing the table to shrink as well), a vertical scrollbar should appear INSIDE the second cell when the table becomes too small to fit all of the content. But in reality, the table just grows vertically, beyond the bounds set by the CSS height attribute(s). Hopefully I've explained this scenario adequately... Does anyone know how I can get this to work?

    Read the article

  • How do you make a CSS-defined table-cell scroll?

    - by Giffyguy
    I want to be able to set the height of the table, and force the cells to scroll individually if they are larger than the table. Consider the following code: (see it in action here) <div style="display: table; position: absolute; width: 25%; height: 80%; min-height: 80%; max-height: 80%; left: 0%; top: 10%; right: 75%; bottom: 10%; border: solid 1px black;"> <div style="display: table-row;"> <div style="display: table-cell; border: solid 1px blue;"> {Some dynamic text content}<br/> This cell should shrink to fit it's contents. </div> </div> <div style="display: table-row;"> <div style="display: table-cell; border: solid 1px red; overflow: scroll;"> This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. This should only take up the remainder of the table's vertical space. </div> </div> </div> If you open this code (in IE8, in my case) you'll notice that the second cell fits in the table nicely when the browser is maximized. In theory, when you shrink the browser (forcing the table to shrink as well), a vertical scrollbar should appear INSIDE the second cell when the table becomes too small to fit all of the content. But in reality, the table just grows vertically, beyond the bounds set by the CSS height attribute(s). Hopefully I've explained this scenario adequately... Does anyone know how I can get this to work?

    Read the article

  • Android: Context menu doesn't show up for ListView with members defined by LinearLayout?

    - by RandomEngy
    I've got a ListActivity and ListView and I've bound some data to it. The data shows up fine, and I've also registered a context menu for the view. When I display the list items as just a simple TextView, it works fine: <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/nametext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> However when I try something a bit more complex, like show the name and a CheckBox, the menu never shows up: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/nametext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <CheckBox android:id="@+id/namecheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> Can long-presses work on more complex elements? I'm building on 2.1.

    Read the article

  • How do I enumerate a list of interfaces that are directly defined on an inheriting class/interface?

    - by Jordan
    Given the following C# class: public class Foo : IEnumerable<int> { // implementation of Foo and all its inherited interfaces } I want a method like the following that doesn't fail on the assertions: public void SomeMethod() { // This doesn't work Type[] interfaces = typeof(Foo).GetInterfaces(); Debug.Assert(interfaces != null); Debug.Assert(interfaces.Length == 1); Debug.Assert(interfaces[0] == typeof(IEnumerable<int>)); } Can someone help by fixing this method so the assertions don't fail? Calling typeof(Foo).GetInterfaces() doesn't work because it returns the entire interface hierarchy (i.e. interfaces variable contains IEnumerable<int> and IEnumerable), not just the top level.

    Read the article

  • Is there a way to effect user defined data types in MySQL?

    - by Dancrumb
    I have a database which stores (among other things), the following pieces of information: Hardware IDs BIGINTs Storage Capacities BIGINTs Hardware Names VARCHARs World Wide Port Names VARCHARs I'd like to be able to capture a more refined definition of these datatypes. For instance, the hardware IDs have no numerical significance, so I don't care how they are formatted when displayed. The Storage Capacities, however, are cardinal numbers and, at a user's request, I'd like to present them with thousands and decimal separators, e.g. 123,456.789. Thus, I'd like to refine BIGINT into, say ID_NUMBER and CARDINAL. The same with Hardware Names, which are simple text and WWPNs, which are hexstrings, e.g. 24:68:AC:E0. Thus, I'd like to refine VARCHAR into ENGLISH_WORD and HEXSTRING. The specific datatypes I made up are just for illustrative purposes. I'd like to keep all this information in one place and I'm wondering if anybody knows of a good way to hold this all in my MySQL table definitions. I could use the Comment field of the table definition, but that smells fishy to me. One approach would be to define the data structure elsewhere and use that definition to generate my CREATE TABLEs, but that would be a major rework of the code that I currently have, so I'm looking for alternatives. Any suggestions? The application language in use is Perl, if that helps.

    Read the article

  • In which DLL is the COM interface iStream defined?

    - by Youval Bronicki
    I'm a complete newbie to Windows and COM programming, trying to use com4j in order to call a COM object from Java. Com4j generates Java interfaces from COM definitions "often found in .ocx, .dll, .exe, and/or .tlb files" . It was easy for me to locate the .ocx file of my target COM object, but I have no clue regarding the standard interface iStream. Microsoft's documentation mentions OLE32.DLL ( c:\Windows\Windows32\Ole32.dll ?) , but neither the com4j generator nor oleviewer succeed in opening this file. Any hints?

    Read the article

  • Problem with memset after an instance of a user defined class is created and a file is opened

    - by Liberalkid
    I'm having a weird problem with memset, that was something to do with a class I'm creating before it and a file I'm opening in the constructor. The class I'm working with normally reads in an array and transforms it into another array, but that's not important. The class I'm working with is: #include <vector> #include <algorithm> using namespace std; class PreProcess { public: PreProcess(char* fileName,char* outFileName); void SortedOrder(); private: vector< vector<double > > matrix; void SortRow(vector<double> &row); char* newFileName; vector< pair<double,int> > rowSorted; }; The other functions aren't important, because I've stopped calling them and the problem persists. Essentially I've narrowed it down to my constructor: PreProcess::PreProcess(char* fileName,char* outFileName):newFileName(outFileName){ ifstream input(fileName); input.close(); //this statement is inconsequential } I also read in the file in my constructor, but I've found that the problem persists if I don't read in the matrix and just open the file. Essentially I've narrowed it down to if I comment out those two lines the memset works properly, otherwise it doesn't. Now to the context of the problem I'm having with it: I wrote my own simple wrapper class for matrices. It doesn't have much functionality, I just need 2D arrays in the next part of my project and having a class handle everything makes more sense to me. The header file: #include <iostream> using namespace std; class Matrix{ public: Matrix(int r,int c); int &operator()(int i,int j) {//I know I should check my bounds here return matrix[i*columns+j]; } ~Matrix(); const void Display(); private: int *matrix; const int rows; const int columns; }; Driver: #include "Matrix.h" #include <string> using namespace std; Matrix::Matrix(int r,int c):rows(r),columns(c) { matrix=new int[rows*columns]; memset(matrix,0,sizeof(matrix)); } const void Matrix::Display(){ for(int i=0;i<rows;i++){ for(int j=0;j<columns;j++) cout << (*this)(i,j) << " "; cout << endl; } } Matrix::~Matrix() { delete matrix; } My main program runs: PreProcess test1(argv[1],argv[2]); //test1.SortedOrder(); Matrix test(10,10); test.Display(); And when I run this with the input line uncommented I get: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1371727776 32698 -1 0 0 0 0 0 6332656 0 -1 -1 0 0 6332672 0 0 0 0 0 0 0 0 0 0 0 0 0 -1371732704 32698 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I really don't have a clue what's going on in memory to cause this, on a side note if I replace memset with: for(int i=0;i<rows*columns;i++) *(matrix+i) &= 0x0; Then it works perfectly, it also works if I don't open the file. If it helps I'm running GCC 64-bit version 4.2.4 on Ubuntu.I assume there's some functionality of memset that I'm not properly understanding.

    Read the article

  • I am trying to use user-defined functions to print out an inputted letter out of stars, but i need h

    - by lm
    def horizline(col): for col in range (col): print("*", end='') print() def vertline(rows, col): for rows in range (rows-2): print ("*", end='') for col in range (col-2): print(' ', end='') print("*") def functionA(width): horizline(width) vereline(width) horizline(width) vertline(width) print() #def funtionB(width): #def functionC(width): #def functionE(width): def main(): width=int(input("Please enter a width for the letter: ")) lenght=int(input("Please enter a lenght for the letter: ")) letter=input("Enter one of the capital letters: A,B,C,E ") if(width>=5 and width<=20): functionA functionB(width,length) functionC(width,length) functionE(width,length) else: print("You have entered an incorrect value") main()

    Read the article

  • How this is code is getting compiled even though we are using a constant which is defined later?

    - by GK
    In the following code DEFAULT_CACHE_SIZE is declared later, but it is used to assign a value to String variable before than that, so was curious how is it possible? public class Test { public String getName() { return this.name; } public int getCacheSize() { return this.cacheSize; } public synchronized void setCacheSize(int size) { this.cacheSize = size; System.out.println("Cache size now " + this.cacheSize); } private final String name = "Reginald"; private int cacheSize = DEFAULT_CACHE_SIZE; private static final int DEFAULT_CACHE_SIZE = 200; }

    Read the article

  • using the window object for accessing global user defined objects and using text within html for cre

    - by timpone
    I don't do very much jquery / javascript but wanted to ask for some advice on the following piece. I have tried to cut out as much as possible. Most of this was semi-inherited code with catching a bunch of events just hardcoded in. I'd like to generalized them more by putting the object name in the html and accessing via jquery on processing (by_date, by_popularity). I retriev as string and access the object via window[current_obj]. Is this a good way to do this or am I missing something? Are there preferable ways to introduce specificity. thanks for any advice. <script> var by_date={}; by_date.current_page=1; by_date.per_page=4; var by_popularity={}; by_popularity.current_page=1; by_popularity.per_page=4; $(function(){ $('.previous.active').live('click',function(){ window[current_obj].current_page--; process(window[current_obj]); }); }); function process(game_obj){ //will process and output new items here } </script> <div class="otherContainer"> <a class='previous active'>Prev</a><div style="display:none;">by_date</div> | <a class='next'>Next</a><div style="display:none;">by_date</div> </div> <div class="topPrevNextContainer"> <a class='previous active'>Prev</a><div style="display:none;">by_popularity</div> | <a class='next'>Next</a><div style="display:none;">by_popularity</div> </div>

    Read the article

  • how can I handle user defined exceptions and after handling them resume the flow of program. here is

    - by fari
    /** * An exception thrown when an illegal side pit was * specified (i.e. not in the range 1-6) for a move */ public class IllegalSidePitNumException extends RuntimeException { /** * Exception constructor. * @param sidePitNum the illegal side pit that was selected. */ public IllegalSidePitNumException(int sidePitNum) { super("No such side pit number: "+sidePitNum); } } how do i use this ina program and then resume for there. I do not want the program to end but want to handle the exception and continue.

    Read the article

  • How can I grab the iTunes-defined name for my iPhone/iPod device?

    - by Christophe Porteneuve
    Hey there, I'm trying to get the name for an iPhone/iPod device that the user entered in their iTunes. This is not, I repeat, not, necessarily what [[UIDevice currentDevice] name] returns (or any of its other methods). For instance, my iPhone is bound in iTunes to "iPhone 3G de Christophe…", to differentiate it from my wife's and other similar devices. That's the name I'd love to be able to grab. Is it stored anywhere on the device, and if so can I access it somehow? Thanks!

    Read the article

  • Whats the scope of a c function defined within objective-c class?

    - by roja
    I was reading up about bypassing objective-c's messaging to gain performance (irrelevant to this specific question) when i found an interesting bit of code: #import <Cocoa/Cocoa.h> @interface Fib : NSObject { } - (long long) cFib: (NSUInteger) number; @end @implementation Fib // c implementation of fib long long cFibIMP(NSUInteger number) { return (number < 3) ? 1 : cFib(number - 1) + cFib(number - 2); } // method wrapper for c implementation of fib - (long long) cFib: (NSUInteger) number { return cFibIMP(number); } @end My question is; when using c function, within an objective-c object, what scope is the c function (cFibIMP in this particular case) placed in? Does the objective-c class encapsulate the c function removing change of name-clash or is the c function simply dumped into the global scope of the whole objective-c program?

    Read the article

  • How to pass the structure to a function in C++ defined in another class?

    - by Dany
    I have a class Con as this:- class Con { public: struct MachineList { BSTR AccountId; BSTR MachineId; BSTR Make; char* Make1; BSTR Model; char* Model1; BSTR SerialNumber; BSTR IpAddress; char* IpAddress1; BSTR Port; int Port1; BSTR LocationCode; } machinelist[100] ; int w; } ; i created an object of Con class as Con m_con; I have another class Test class Test { public: void fun();//i want to pass the object of the structure that i created in Con //what arguments should i pass in fun function? };

    Read the article

  • First Call to a Controller, Constant is defined, Second call, "uninitialized constant Oauth"?

    - by viatropos
    I am trying to get the OAuth gem to work with Rails 3 and I'm running into this weird problem... (independent of the gem, I think I've run into this once before) I have a controller called "OauthTestController", and a model called "ConsumerToken". The model looks like this. require 'oauth/models/consumers/token' class ConsumerToken < ActiveRecord::Base include Oauth::Models::Consumers::Token end When I go to "/oauth_test/twitter", it loads the Oauth::Models::Consumers::Token module and I'm able to connect to twitter no problem. But the second time I try it (just refresh the /oauth_test/twitter url), it gives me this error: NameError (uninitialized constant Oauth): app/models/consumer_token.rb:4 app/models/twitter_token.rb:2 app/controllers/oauth_test_controller.rb:66:in `load_consumer' Why is that? It has something to do with load paths or being in development mode maybe?

    Read the article

  • Can you define <=> in Ruby and then have ==, >, <, >=, and <= defined automatically?

    - by jeremy Ruten
    Here's part of my Note class: class Note attr_accessor :semitones, :letter, :accidental def initialize(semitones, letter, accidental = :n) @semitones, @letter, @accidental = semitones, letter, accidental end def <=>(other) @semitones <=> other.semitones end def ==(other) @semitones == other.semitones end def >(other) @semitones > other.semitones end def <(other) @semitones < other.semitones end end It seems to me like there should be a module that I could include that could give me my equality and comparison operators based on my <=> method. Is there one? I'm guessing a lot of people run into this kind of problem. How do you usually solve it? (How do you make it DRY?)

    Read the article

  • How to reliably replace a library-defined error handler with my own?

    - by sharptooth
    On certain error cases ATL invokes AtlThrow() which is implemented as ATL::AtlThrowImpl() which in turn throws CAtlException. The latter is not very good - CAtlException is not even derived from std::exception and also we use our own exceptions hierarchy and now we will have to catch CAtlException separately here and there which is lots of extra code and error-prone. Looks like it is possible to replace ATL::AtlThrowImpl() with my own handler - define _ATL_CUSTOM_THROW and define AtlThrow() to be the custom handler before including atlbase.h - and ATL will call the custom handler. Not so easy. Some of ATL code is not in sources - it comes compiled as a library - either static or dynamic. We use the static - atls.lib. And... it is compiled in such way that it has ATL::ThrowImpl() inside and some code calling it. I used a static analysis tool - it clearly shows that there're paths on which the old default handler is called. To ensure I even tried to "reimplement" ATL::AtlThrowImpl() in my code. Now the linker says it sees two declarations of ATL::AtlThrowImpl() which I suppose confirms that there's another implementation that can be called by some code. How can I handle this? How do I replace the default handler completely and ensure that the default handler is never called?

    Read the article

  • does the order a composite key is defined matter?

    I have a table with (col1,col2) as a composite primary key. create table twokeytable(col1 int,col2 int,constraint twokeytable_pk primary key (col1,col2)); and another table with col3,col4 collumns witha composite foreign key(col3,col4) which references the(col1,col2) primary key. For some processing I need to drop the foreign key and primary constraints .While restoring the constraints does order of the keys matter?. are these same? create table fktwokeytable(col3 int,col4 int,constraint fkaddfaa_fk foreign key(col4,col3) references twokeytable(col1,col2)) and create table fktwokeytable(col3 int,col4 int,constraint fkaddfaa_fk foreign key(col3,col4) references twokeytable(col1,col2))

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >