methods

Error when call method from another class in android

痞子三分冷 提交于 2019-12-12 06:49:29
问题 i have 2 class. One is MainBaby.java and it contains: public class MainBaby extends SurfaceView implements SurfaceHolder.Callback { public MainBaby(Context context){ super(context); init(); } public MainBaby(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub init(); } public MainBaby(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub init(); } public void init(){ //

Why are my TextViews null?

一笑奈何 提交于 2019-12-12 06:38:20
问题 I want if the user enters an invalid number, two TextView s should change their texts. I looked up and checked if I got more than one TextView with the same id and the ruesult was that each id from my TextView s are unique. Everytime I force my error with entering an invalid number my app crashes. If i start the app in debug and marked my two "problematic codes". The result was both TextView s were null . I don't know why this happens because the id's are unique and I don't change my current

Printing out variables from different methods in java?

*爱你&永不变心* 提交于 2019-12-12 05:31:22
问题 I have to use different methods for this code, no java shortcuts! Here is my code: import java.io.*; import java.util.Scanner; public class pg3a { public static void main(String[] args) throws IOException { Scanner keyboard = new Scanner(System.in); String hex; char choice = 'y'; boolean isValid = false; do { switch (choice) { case 'y': System.out.print("Do you want to enter a hexadecimal number? "); System.out.print("y or n?: "); choice = keyboard.next().charAt(0); System.out.print("Enter a

AddHandler event on dynamic button, incorrect instance properties in VB.NET

拟墨画扇 提交于 2019-12-12 05:27:12
问题 I'm new to custom classes. I have a class called 'game'. In the class, I have a method called 'addGame()' that creates a dynamic picture box called 'pBox'. After creating the control, I'm doing the following to register a click event: AddHandler pBox.Click, AddressOf Me.launchGame And here is launchGame: Public Sub launchGame() MsgBox(Me.name) End Sub The problem is, "Me.name" is always the most recently added instances name, not the one I clicked on. Based on a suggestion, I also tried this:

Help with explanation

青春壹個敷衍的年華 提交于 2019-12-12 05:25:44
问题 I have some codes that i find very hard to understand. Can someone help me break it down line by line? Service1Client client = new Service1Client(); client.getPrimaryListCompleted += new EventHandler<getPrimaryListCompletedEventArgs>(AddPrimaryMarkerGraphics); client.getPrimaryListAsync(); 回答1: The first line creates an instance of the class Service1Client . The second line hooks up an event handler for the event getPrimaryListCompleted . the third line starts an asynchronous request. When

Recursion wrong output

醉酒当歌 提交于 2019-12-12 05:20:35
问题 I am given the following code int go(int x){ if (x<1) return 1; else return x + go(x-2) + go(x-3); } The answer is 7 by calling go(3) but everytime I do it (I have to do it by hand) I get 8. This is my logic: 3 + go(1) + go(0)/1 = 3 + go(1) + 1(because 0 is less than 1) Then, 3 + go(-1) = 3 + 1 Therefore, 3 + 4 + 1 = 8. What am I doing wrong? 回答1: It sounds like you made mistake as go(1) = 3 + go(1-2) where the actual formula is go(1) = 1 + go(1-2) + go(1-3) . go(3) = 3 + go(1) + go(0) = 3 +

this operation is not supported in the WCF test client(WCF + ENTITY DATA MODEL)

微笑、不失礼 提交于 2019-12-12 05:18:32
问题 I am getting the error this operation is not supported in the wcf test client because it uses type catNameService.catNames[] Class and IClass code: catService class: namespace catNameService { class catService:IcatService { public IEnumerable<catNames> sortBySex(int genderNumber) { using (var context = new catNamingEntities()) { return context.catNames.Where(t => t.Gender == genderNumber).ToList(); } } } } IcatService interface: namespace catNameService { [ServiceContract] public interface

Trying to create a portfolio of stocks with a total value in Objective-C, but unsure of the approach

点点圈 提交于 2019-12-12 05:16:04
问题 I'm currently teaching myself Objective-C with the Big Nerd Ranch guide (2nd edition) and I have not had a problem up until chapter 21. I checked the book's forum, but it was of no help because most people there are newbies with spaghetti code, and I do not want to adopt bad habits...I am a beginner too, as this is my first major language, but spaghetti code is obvious when you see it. I have to take my code from a previous chapter and make a tool that creates an instance of a BNRPortfolio

Path method displayed with rake routes is still undefined

有些话、适合烂在心里 提交于 2019-12-12 05:15:08
问题 After getting rid of this question, I get one another. I have a path method specified in routes resources :tree_nurseries do ... . And shows correctly when I do rake routes which gives new_tree_nursery then normally new_tree_nursery_path will be available. But, when I call it with a link_to method, it remains undefiend.... ( new_tree_nursery_path ) What did I missed again? this is the code line : .actions = link_to t('.new', :default => t("helpers.links.new")), new_tree_nursery_path, :class =

Need help using REF and Arrays, and Methods

老子叫甜甜 提交于 2019-12-12 05:12:09
问题 Ok, I'm doing my lab from C# class which involve using ref parameters, arrays, and methods. There is a few problems which I encounter while doing this and I'm begging for help. So.. First I modified problem into simplest chunks to help me explain which problems I have. Here is a piece of simplified code: using System; public class Repository { string[] titles; static void Main(string[] args) { string title; Console.Write("Title of book: "); title = Console.ReadLine(); getBookInfo(ref title);