Search Results

Search found 33969 results on 1359 pages for 'custom view'.

Page 10/1359 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Effectively implementing a game view using java

    - by kdavis8
    I am writing a 2d game in java. The game mechanics are similar to the Pokémon game boy advance series e.g. fire red, ruby, diamond and so on. I need a way to draw a huge map maybe 5000 by 5000 pixels and then load individual in game sprites to across the entirety of the map, like rendering a scene. Game sprites would be things like terrain objects, trees, rocks, bushes, also houses, castles, NPC's and so on. But i also need to implement some kind of camera view class that focuses on the player. the camera view class needs to follow the characters movements throughout the game map but it also needs to clip the rest of the map away from the user's field of view, so that the user can only see the arbitrary proximity adjacent to the player's sprite. The proximity's range could be something like 500 pixels in every direction around the player’s sprite. On top of this, i need to implement an independent resolution for the game world so that the game view will be uniform on all screen sizes and screen resolutions. I know that this does sound like a handful and may fall under the category of multiple questions, but the questions are all related and any advice would be very much appreciated. I don’t need a full source code listing but maybe some pointers to effective java API classes that could make doing what i need to do a lot simpler. Also any algorithmic/ design advice would greatly benefit me as well. example of what i am trying to do in source code form below package myPackage; /** * The Purpose of GameView is to: Render a scene using Scene class, Create a * clipping pane using CameraView class, and finally instantiate a coordinate * grid using Path class. * * Once all of these things have been done, GameView class should then be * instantiated and used jointly with its helper classes. CameraView should be * used as the main drawing image. CameraView is the the window to the game * world.Scene passes data constantly to CameraView so that the entire map flows * smoothly. Path uses the x and y coordinates from camera view to construct * cells for path finding algorithms. */ public class GameView { // Scene is a helper class to game view. it renders the entire map to memory // for the camera view. Scene scene; // Camera View is a helper class to game view. It clips the Scene into a // small image that follows the players coordinates. CameraView Camera; // Path is a helper class to game view. It observes and calculates the // coordinates of camera view and divides them into Grids/Cells for Path // finding. Path path; // this represents the player and has a getSprite() method that will return // the current frame column row combination of the passed sprite sheet. Sprite player; }

    Read the article

  • Extending Zend View Helper Placeholder

    - by Sonny
    I was reading the manual about basic placeholder usage, and it has this example: class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { // ... protected function _initSidebar() { $this->bootstrap('View'); $view = $this->getResource('View'); $view->placeholder('sidebar') // "prefix" -> markup to emit once before all items in collection ->setPrefix("<div class=\"sidebar\">\n <div class=\"block\">\n") // "separator" -> markup to emit between items in a collection ->setSeparator("</div>\n <div class=\"block\">\n") // "postfix" -> markup to emit once after all items in a collection ->setPostfix("</div>\n</div>"); } // ... } I want to acommplish almost exactly that, but I'd like to conditionally add more class values to the repeating divs, at time of rendering if possible, when all the content is in the placeholder. One thing I specifically want to do is add the class of "first" to the first element and "last" to the last element. I assume that I'll have to extend the Zend_View_Helper_Placeholder class to accomplish this.

    Read the article

  • Calling a method in a view controller from a view

    - by Lakshmie
    I have to invoke a method present in a view controller who's reference is available in the view. When I try to call the method like any other method, for some reason, iPhone just ignores the call. Can somebody explain as to why this happens and also how can I go about invoking this method? In the view I have this method: -(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event{ NSArray* mySubViews = [self subviews]; for (UITouch *touch in touches) { int i = 0; for(; i<[mySubViews count]; i++){ if(CGRectContainsPoint([[mySubViews objectAtIndex:i] frame], [touch locationInView:self])){ break; } } if(i<[mySubViews count]){ // viewController is the reference to the View Controller. [viewController pointToSummary:[touch locationInView:self].y]; NSLog(@"Helloooooo"); break; } } } Whenever the touches event is triggered, Hellooooo gets printed in the console but the method before that is simply ignored

    Read the article

  • iPhone modal view inside another modal view?

    - by Rick
    My App uses a modal view when users add a new foo. The user selects a foo type using this modal view. Depending on what type is selected, the user needs to be asked for more information. I'd like to use another modal view to ask for this extra information. I've tried to create the new modal view like the first one (which works great) and it leads to stack overflow/“Loading Stack Frames” error in Xcode. Am I going about this in completely the wrong way i.e. is this just a really bad idea? Should I rethink the UI itself? UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; [self presentModalViewController:navigationController animated:YES];

    Read the article

  • Changing the Default View Engine's view search behavior.

    - by bradhe
    I'm working with ASP.NET MVC 2. I have a bunch of partial views that I render based on different conditions within the same controller. I'd like to not put the physical partial view files in with the controller's other views. I know that when I want a ViewResult using the View() or PartialView() methods the default view engine will search through the folder in the Views directory associated with the controller (i.e. if my controller is called Register it will look in the Register folder under Views) and also in the Shared folder. Is there any way to change this behavior, or perhaps tell it specifically where to look for the view -- heck, even give it a specific file to render? Is that possible? Perhaps even a sub-folder under the Shared folder will work...

    Read the article

  • iPhone modal View with parent view semi-visible?

    - by Moshe
    I am adding a modal view using the following code: [self presentModalViewController:phrasesEditor animated:YES]; How can I make the modal view semi-transparent so that the superview "shines" through? My complete method/function looks like this: -(IBAction)showEditPhrases:(id)sender{ PhrasesViewController *phrasesEditor = [[PhrasesViewController alloc] initWithNibName:@"PhrasesViewController" bundle:nil]; phrasesEditor.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [phrasesEditor.view setAlpha: 0.5]; [phrasesEditor.view setBackgroundColor: [UIColor clearColor]]; [self presentModalViewController:phrasesEditor animated:YES]; [phrasesEditor release]; }

    Read the article

  • How to draw some lines in a view element defined in the xml layout

    - by Nils
    Hello, I have problems drawing some simple lines in a view object (Android programming). First I created the layout with the view element(kind of painting area) in it (XML file). [...] < View android:id="@+id/viewmap" android:layout_width="572px" android:layout_height="359px" android:layout_x="26px" android:layout_y="27px" [...] ... and tried then to access it to draw some lines. Unfortunately the program is running and other UI elements like buttons are displayed, but I can't see the drawings. What's wrong ? [...] viewmap = (View) findViewById(R.id.viewmap); Canvas canvas = new Canvas(); viewmap.draw(canvas); Paint p = new Paint(); p.setColor(Color.BLUE); p.setStyle(Paint.Style.STROKE); canvas.drawColor(Color.WHITE); p.setColor(Color.BLUE); canvas.drawLine(4, 4, 29, 5, p); p.setColor(Color.RED); viewmap.draw(canvas); [...] Thanks for help :) !

    Read the article

  • Animating translation and scaling of view in Android

    - by hgpc
    I have to animate a view from state A to B with changes to its scale, position and scrolling. I know everything about state A (widthA, heightA, topA, leftA, scrollXA, scrollYA) and state B (widthB, heightB, topB, leftB, scrollXB, scrollYB). So far I wrote the following code: AnimationSet animation = new AnimationSet(true); int toXDelta; // What goes here? int toYDelta; // What goes here? TranslateAnimation translateAnimation = new TranslateAnimation(1, toXDelta, 1, toYDelta); translateAnimation.setDuration(duration); animation.addAnimation(translateAnimation); float scale = (float) widthB / (float) widthA; ScaleAnimation scaleAnimation = new ScaleAnimation(1, scale, 1, scale); scaleAnimation.setDuration(duration); animation.addAnimation(scaleAnimation); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { view.clearAnimation(); // Change view to state B } @Override public void onAnimationRepeat(Animation arg0) {} @Override public void onAnimationStart(Animation arg0) {} }); view.startAnimation(animation); Is this the right way to do this? If so, how should I calculate the values of toXDelta and toYDelta? I'm having trouble finding the exact formula. Thanks!

    Read the article

  • Create a view like Tweetie's User Profile view

    - by Graeme
    Hi, I'm just wondering if anyone has any idea on how you can create a view that looks like the user profile view in apps like Tweetie, where there are seemingly multiple tables with a couple of normal (straight up and down tables) and then two rows of six cells, which in Tweeties case have the number of followers, following etc. I'm trying to make a similar view for my app, but can't seem to find out the best way to create it. Any tutorials, advice etc. would be appreciated. Thanks. P.S. Here's a picture of the view which I'm trying to recreate.

    Read the article

  • iphone sdk: Table view not working in the first 5 tabs but in the more view

    - by LHT
    Hi, I only started with sdk but this problem is bugging me now for a view days: I created a UITableView and added it to my Tabs. When this TableView is in the first 4 Tabs and u go look at it, it only shows the items on the table but when clicking on them nothing happens (it doesn't go to the next view). BUT when i put this same tab behind the 5th so it goes in the automatic MORE view everything works fine. I'm assuming this is because this more view is implementing some kind of table class. But i can't figure it out. I compared all the files with a working example but it seems to be all the same. ah ya my current project is a window based application. Though i copied most of the code from a navigation based application. Any ideas?

    Read the article

  • changing a picker to table view OR having multiple table views on the same view

    - by Brodie4598
    Hello - My iPad app was rejected due to my use of a picker. The picker was used to control a table view. In my view, a picker was displaying a series of items and when one of those items was selected, it used that selection to populate a table with data. (hopefully that makes sense). Now I need to do this without the picker so I need to have the data that was in the picker be represented in a table view. My question, is how do I have multiple tableViews in the same view? I'm guessing I need to have some kind of if statement in the tableview delegate methods, but I'm not quite sure what the if statement needs to be. Or maybe i'm thinking of this the totally wrong way thanks

    Read the article

  • Handle BACK key event in child view

    - by Mick Byrne
    In my app, users can tap on image thumbnails to see a full size version. When the thumbnail is tapped a bunch of new views are created in code (i.e. no XML), appended at the end of the view hierarchy and some scaling and rotating transitions happen, then the full size, high res version of the image is displayed. Tapping on the full size image reverses the transitions and removes the new views from the view hierarchy. I want users to also be able to press the BACK key to reverse the image transitions. However, I can't seem to catch the KeyEvent. This is what I'm trying at the moment: // Set a click listener on the image to reverse everything frameView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { zoomOut(); // This works fine } }); // Set the focus onto the frame and then set a key listener to catch the back buttons frameView.setFocusable(true); frameView.setFocusableInTouchMode(true); frameView.requestFocus(); frameView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // The code never even gets here !!! if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { zoomOut(); return true; } return false; } });

    Read the article

  • Sharing parameters between setting view and application view

    - by Tibi
    Hi there, Simple question : I've got an iPhone app with 2 views with each a separated xib files. one view holds the settings of the app one view holds the app using the settings made in previous view. How should I implement the sharing of setup parameters between the 2 views ? should I manage those parameters in the app delegate ?

    Read the article

  • Model View Control Issue: Null Pointer Initialization Question

    - by David Dimalanta
    Good morning again. This is David. Please, I need an urgent help regarding control model view where I making a code that uniquely separating into groups: An Activity Java Class to Display the Interface A View and Function Java Class for Drawing Cards and Display it on the Activity Class The problem is that the result returns a Null Pointer Exception. I have initialize for the ID for Text View and Image View. Under this class "draw_deck.java". Please help me. Here's my code for draw_deck.java: package com.bodapps.inbetween.model; import android.content.Context; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.bodapps.inbetween.R; public class draw_deck extends View { public TextView count_label; public ImageView draw_card; private int count; public draw_deck(Context context) { super(context); // TODO Auto-generated constructor stub //I have initialized two widgets for ID. I still don't get it why I got forced closed by Null Pointer Exception thing. draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); count_label = (TextView) findViewById(R.id.Text_View_Count_Card); } public void draw(int s, int c, String strSuit, String strValue, Pile pile, Context context) { //super(context); //Just printing the card drawn from pile int suit, value = 1; draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); count_label = (TextView) findViewById(R.id.Text_View_Count_Card); Card card; if(!pile.isEmpty()) //Setting it to IF statement displays the card one by one. { card = pile.drawFromPile(); //Need to check first if card is null. if (card != null) { //draws an extra if (card != null) { //Get suit of card to print out. suit = card.getSuit(); switch (suit) { case CardInfo.DIAMOND: strSuit = "DIAMOND"; s=0; break; case CardInfo.HEART: strSuit = "HEART"; s=1; break; case CardInfo.SPADE: strSuit = "SPADE"; s=2; break; case CardInfo.CLUB: strSuit = "CLUB"; s=3; break; } //Get value of card to print out. value = card.getValue(); switch (value) { case CardInfo.ACE: strValue = "ACE"; c=0; break; case CardInfo.TWO: c=1; break; case CardInfo.THREE: strValue = "THREE"; c=2; break; case CardInfo.FOUR: strValue = "FOUR"; c=3; break; case CardInfo.FIVE: strValue = "FIVE"; c=4; break; case CardInfo.SIX: strValue = "SIX"; c=4; break; case CardInfo.SEVEN: strValue = "SEVEN"; c=4; break; case CardInfo.EIGHT: strValue = "EIGHT"; c=4; break; case CardInfo.NINE: strValue = "NINE"; c=4; break; case CardInfo.TEN: strValue = "TEN"; c=4; break; case CardInfo.JACK: strValue = "JACK"; c=4; break; case CardInfo.QUEEN: strValue = "QUEEN"; c=4; break; case CardInfo.KING: strValue = "KING"; c=4; break; } } } }// //Below two lines of code, this is where issued the Null Pointer Exception. draw_card.setImageResource(deck[s][c]); count_label.setText(new StringBuilder(strValue).append(" of ").append(strSuit).append(String.valueOf(" " + count++)).toString()); } //Choice of Suits in a Deck public Integer[][] deck = { //Array Group 1 is [0][0] (No. of Cards: 4 - DIAMOND) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 2 is [1][0] (No. of Cards: 4 - HEART) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 3 is [2][0] (No. of Cards: 4 - SPADE) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 4 is [3][0] (No. of Cards: 4 - CLUB) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, }; } And this one of the activity class, Player_Mode_2.java: package com.bodapps.inbetween; import java.util.Random; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.bodapps.inbetween.model.Card; import com.bodapps.inbetween.model.Pile; import com.bodapps.inbetween.model.draw_deck; /* * * Public class for Two-Player mode. * */ public class Player_Mode_2 extends Activity { //Image Views private ImageView draw_card; private ImageView player_1; private ImageView player_2; private ImageView icon; //Buttons private Button set_deck; //Edit Texts private EditText enter_no_of_decks; //text Views private TextView count_label; //Integer Data Types private int no_of_cards, count; private int card_multiplier; //Contexts final Context context = this; //Pile Model public Pile pile; //Card Model public Card card; //create View @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.play_2_player_mode); //-----[ Search for Views ]----- //Initialize for Image View draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); player_1 = (ImageView) findViewById(R.id.IV_Player_1_Card); player_2 = (ImageView) findViewById(R.id.IV_Player_2_Card); //Initialize for Text view or Label count_label = (TextView) findViewById(R.id.Text_View_Count_Card); //-----[ Adding Values ]----- //Integer Values count = 0; no_of_cards = 0; //-----[ Adding Dialog ]----- //Initializing Dialog final Dialog deck_dialog = new Dialog(context); deck_dialog.setContentView(R.layout.dialog); deck_dialog.setTitle("Deck Dialog"); //-----[ Initializing Views for Dialog's Contents ]----- //Initialize for Edit Text enter_no_of_decks = (EditText) deck_dialog.findViewById(R.id.Edit_Text_Set_Number_of_Decks); //Initialize for Button set_deck = (Button) deck_dialog.findViewById(R.id.Button_Deck); //-----[ Setting onClickListener() ]----- //Set Event Listener for Image view draw_card.setOnClickListener(new Draw_Card_Model()); //Set Event Listener for Setting the Deck set_deck.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(card_multiplier <= 8) { //Use "Integer.parseInt()" method to instantly convert from String to int value. card_multiplier = Integer.parseInt(enter_no_of_decks.getText().toString()); //Shuffling cards... pile = new Pile(card_multiplier); //Multiply no. of decks //Dismiss or close the dialog. deck_dialog.dismiss(); } else { Toast.makeText(getApplicationContext(), "Please choose a number from 1 to 8.", Toast.LENGTH_SHORT).show(); } } }); //Show dialog. deck_dialog.show(); } //Shuffling the Array public void Shuffle_Cards(Integer[][] Shuffle_Deck) { Random random = new Random(); for(int i = Shuffle_Deck[no_of_cards].length - 1; i >=0; i--) { int Index = random.nextInt(i + 1); //Simple Swapping Integer swap = Shuffle_Deck[card_multiplier-1][Index]; Shuffle_Deck[card_multiplier-1][Index] = Shuffle_Deck[card_multiplier-1][i]; Shuffle_Deck[card_multiplier-1][i] = swap; } } //Private Class for Random Card Draw private class Draw_Card_Model implements OnClickListener { public void onClick(View v) { //Just printing the card drawn from pile int suit = 0, value = 0; String strSuit = "", strValue = ""; draw_deck draw = new draw_deck(context); //This line is where issued the Null Pointer Exception. if (count == card_multiplier*52) { // A message shows up when all cards are draw out. Toast.makeText(getApplicationContext(), "All cards have been used up.", Toast.LENGTH_SHORT).show(); draw_card.setEnabled(false); } else { draw.draw(suit, value, strSuit, strValue, pile, context); count_label.setText(count); //This is where I got force closed error, although "int count" have initialized the number. This was supposed to accept in the setText() method. count++; } } } } Take note that the issues on Null Pointer Exception is the Image View and the Edit Text. I got to test it. Thanks. If you have any info about my question, let me know it frankly.

    Read the article

  • Model View Control Issue: Null Pointer Initialization Question [closed]

    - by David Dimalanta
    Good morning again. This is David. Please, I need an urgent help regarding control model view where I making a code that uniquely separating into groups: An Activity Java Class to Display the Interface A View and Function Java Class for Drawing Cards and Display it on the Activity Class The problem is that the result returns a Null Pointer Exception. I have initialize for the ID for Text View and Image View. Under this class "draw_deck.java". Please help me. Here's my code for draw_deck.java: package com.bodapps.inbetween.model; import android.content.Context; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.bodapps.inbetween.R; public class draw_deck extends View { public TextView count_label; public ImageView draw_card; private int count; public draw_deck(Context context) { super(context); // TODO Auto-generated constructor stub //I have initialized two widgets for ID. I still don't get it why I got forced closed by Null Pointer Exception thing. draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); count_label = (TextView) findViewById(R.id.Text_View_Count_Card); } public void draw(int s, int c, String strSuit, String strValue, Pile pile, Context context) { //super(context); //Just printing the card drawn from pile int suit, value = 1; draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); count_label = (TextView) findViewById(R.id.Text_View_Count_Card); Card card; if(!pile.isEmpty()) //Setting it to IF statement displays the card one by one. { card = pile.drawFromPile(); //Need to check first if card is null. if (card != null) { //draws an extra if (card != null) { //Get suit of card to print out. suit = card.getSuit(); switch (suit) { case CardInfo.DIAMOND: strSuit = "DIAMOND"; s=0; break; case CardInfo.HEART: strSuit = "HEART"; s=1; break; case CardInfo.SPADE: strSuit = "SPADE"; s=2; break; case CardInfo.CLUB: strSuit = "CLUB"; s=3; break; } //Get value of card to print out. value = card.getValue(); switch (value) { case CardInfo.ACE: strValue = "ACE"; c=0; break; case CardInfo.TWO: c=1; break; case CardInfo.THREE: strValue = "THREE"; c=2; break; case CardInfo.FOUR: strValue = "FOUR"; c=3; break; case CardInfo.FIVE: strValue = "FIVE"; c=4; break; case CardInfo.SIX: strValue = "SIX"; c=4; break; case CardInfo.SEVEN: strValue = "SEVEN"; c=4; break; case CardInfo.EIGHT: strValue = "EIGHT"; c=4; break; case CardInfo.NINE: strValue = "NINE"; c=4; break; case CardInfo.TEN: strValue = "TEN"; c=4; break; case CardInfo.JACK: strValue = "JACK"; c=4; break; case CardInfo.QUEEN: strValue = "QUEEN"; c=4; break; case CardInfo.KING: strValue = "KING"; c=4; break; } } } }// //Below two lines of code, this is where issued the Null Pointer Exception. draw_card.setImageResource(deck[s][c]); count_label.setText(new StringBuilder(strValue).append(" of ").append(strSuit).append(String.valueOf(" " + count++)).toString()); } //Choice of Suits in a Deck public Integer[][] deck = { //Array Group 1 is [0][0] (No. of Cards: 4 - DIAMOND) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 2 is [1][0] (No. of Cards: 4 - HEART) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 3 is [2][0] (No. of Cards: 4 - SPADE) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, //Array Group 4 is [3][0] (No. of Cards: 4 - CLUB) { R.drawable.card_dummy_1, R.drawable.card_dummy_2, R.drawable.card_dummy_4, R.drawable.card_dummy_5, R.drawable.card_dummy_3 }, }; } And this one of the activity class, Player_Mode_2.java: package com.bodapps.inbetween; import java.util.Random; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.bodapps.inbetween.model.Card; import com.bodapps.inbetween.model.Pile; import com.bodapps.inbetween.model.draw_deck; /* * * Public class for Two-Player mode. * */ public class Player_Mode_2 extends Activity { //Image Views private ImageView draw_card; private ImageView player_1; private ImageView player_2; private ImageView icon; //Buttons private Button set_deck; //Edit Texts private EditText enter_no_of_decks; //text Views private TextView count_label; //Integer Data Types private int no_of_cards, count; private int card_multiplier; //Contexts final Context context = this; //Pile Model public Pile pile; //Card Model public Card card; //create View @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.play_2_player_mode); //-----[ Search for Views ]----- //Initialize for Image View draw_card = (ImageView) findViewById(R.id.IV_Draw_Card); player_1 = (ImageView) findViewById(R.id.IV_Player_1_Card); player_2 = (ImageView) findViewById(R.id.IV_Player_2_Card); //Initialize for Text view or Label count_label = (TextView) findViewById(R.id.Text_View_Count_Card); //-----[ Adding Values ]----- //Integer Values count = 0; no_of_cards = 0; //-----[ Adding Dialog ]----- //Initializing Dialog final Dialog deck_dialog = new Dialog(context); deck_dialog.setContentView(R.layout.dialog); deck_dialog.setTitle("Deck Dialog"); //-----[ Initializing Views for Dialog's Contents ]----- //Initialize for Edit Text enter_no_of_decks = (EditText) deck_dialog.findViewById(R.id.Edit_Text_Set_Number_of_Decks); //Initialize for Button set_deck = (Button) deck_dialog.findViewById(R.id.Button_Deck); //-----[ Setting onClickListener() ]----- //Set Event Listener for Image view draw_card.setOnClickListener(new Draw_Card_Model()); //Set Event Listener for Setting the Deck set_deck.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(card_multiplier <= 8) { //Use "Integer.parseInt()" method to instantly convert from String to int value. card_multiplier = Integer.parseInt(enter_no_of_decks.getText().toString()); //Shuffling cards... pile = new Pile(card_multiplier); //Multiply no. of decks //Dismiss or close the dialog. deck_dialog.dismiss(); } else { Toast.makeText(getApplicationContext(), "Please choose a number from 1 to 8.", Toast.LENGTH_SHORT).show(); } } }); //Show dialog. deck_dialog.show(); } //Shuffling the Array public void Shuffle_Cards(Integer[][] Shuffle_Deck) { Random random = new Random(); for(int i = Shuffle_Deck[no_of_cards].length - 1; i >=0; i--) { int Index = random.nextInt(i + 1); //Simple Swapping Integer swap = Shuffle_Deck[card_multiplier-1][Index]; Shuffle_Deck[card_multiplier-1][Index] = Shuffle_Deck[card_multiplier-1][i]; Shuffle_Deck[card_multiplier-1][i] = swap; } } //Private Class for Random Card Draw private class Draw_Card_Model implements OnClickListener { public void onClick(View v) { //Just printing the card drawn from pile int suit = 0, value = 0; String strSuit = "", strValue = ""; draw_deck draw = new draw_deck(context); //This line is where issued the Null Pointer Exception. if (count == card_multiplier*52) { // A message shows up when all cards are draw out. Toast.makeText(getApplicationContext(), "All cards have been used up.", Toast.LENGTH_SHORT).show(); draw_card.setEnabled(false); } else { draw.draw(suit, value, strSuit, strValue, pile, context); count_label.setText(count); //This is where I got force closed error, although "int count" have initialized the number. This was supposed to accept in the setText() method. count++; } } } } Take note that the issues on Null Pointer Exception is the Image View and the Edit Text. I got to test it. Thanks. If you have any info about my question, let me know it frankly.

    Read the article

  • No video signal at boot with custom built computer

    - by Bart Pelle
    After booting my custom built computer, neither the VGA nor the HDMI methods from the video card seem to emit any signal to the display. I have tested both a regular VGA screen and a modern HDMI screen. Both did not receive signal. Below are the specifications from my computer build: Intel Core i5 3350P ASRock B75 Pro 3-M Seagate Barracuda 7200.14 ST1000 DM003 1000GB Corsair Vengeance LP CML 8GX 3M2 A1600 CGB Blue (2 cards) Cooler Master B Series B600 Club 3D Radeon HD7870 XT Jokercard Samsung SH-224 BB Black Sharkoon T28 Case The motherboard does not emit any beeps on startup. The CD tray opens properly and all fans spin. All cables are properly connected. All components are new and no damage was found on any of the components. The fans on the GPU spin aswell. The VGA test we did was by using the onboard graphics from the Intel i5, but this gave no result. The HDMI test was from the GPU which did not emit any signal either. We have not been able to test out the DVI, could this be important to test, even though all the other methods did not work? Thank you for your time and hopefully reply.

    Read the article

  • Rendering spatial data of GeoQuerySet in a custom view on GeoDjango

    - by dmytro
    Hello. I have just started my first project on GeoDjango. As a matter of fact, with GeoDjango powered Admin application we all have a great possibility to view/edit spatial data, associated with the current object. The problem is that after the objects having been populated I need to render several objects' associated geometry at once on a single map. I might implement it as a model action, redirecting to a custom view. I just don't know, how to include the OpenLayers widget in the view and how to render there my compound geometry from my GeoQuerySet. I would be very thankful for any hint from an experienced GeoDjango programmer.

    Read the article

  • mysql view performance

    - by vamsivanka
    I have a table for about 100,000 users in it. First Case: explain select * from users where state = 'ca' when i do an explain plan for the above query i got the cost as 5200 Second Case: Create or replace view vw_users as select * from users Explain select * from vw_users where state = 'ca' when i do an explain plan on the second query i got the cost as 100,000. How does the where clause in the view work ?? Is the where clause applied after the view retrieves all the rows. Please let know, how can i fix this issue. Thanks

    Read the article

  • View Animation (Resizing a Ball)

    - by user270811
    hi, i am trying to do this: 1) user long touches the screen, 2) a circle/ball pops up (centered around the user's finger) and grows in size as long as the user is touching the screen 3) once the user lets go of the finger, the ball (now in its final size) will bounce around. i think i have the bouncing around figure out from the DivideAndConquer example, but i am not sure how to animate the ball's growth. i looked at various view flipper examples such as this: http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html but it seems like view flipper is best for swapping two static pictures. i wasn't able to find a good view animator example other than the flippers. also, i would prefer to use images as opposed to just a circle. can someone point me in the right direction? thanks.

    Read the article

  • Help with MVC controller: passing a string from view to controller

    - by 109221793
    Hi guys, I'm having trouble with one particular issue, I was hoping someone could help me out. I've completed the MVC Music Store tutorial, and now I'm trying to add some administrator functionality - practice as I will have to do this in an MVC application in my job. The application is using the aspnet membership api, and what I have done so far is created a view to list the users. What I want to be able to do, is click on the users name in order to change their password. To try and carry the username to the changeUserPassword controller (custom made). I registered a new route in the global.asax.cs file in order to display the username in the URL, which is working so far. UserList View <%: Html.RouteLink(user.UserName, "AdminPassword", new { controller="StoreManager", action="changeUserPassword", username = user.UserName }) %> Global.asax.cs routes.MapRoute( "AdminPassword", //Route name "{controller}/{action}/{username}", //URL with parameters new { controller = "StoreManager", action = "changeUserPassword", username = UrlParameter.Optional} ); So now the URL looks like this when I reach the changeUserPassword view: http://localhost:51236/StoreManager/changeUserPassword/Administrator Here is the GET changeUserPassword action: public ActionResult changeUserPassword(string username) { ViewData["username"] = username; return View(); } I wanted to store the username in ViewData as I would like to use it in the GET changeUserPassword for display purposes, and also as a hidden value in the form. This is in order to pass it through to enable me to reset the password. Having debugged through the code, it seems that 'username' is null. How can I get this to work so that the username carries over from the Html.RouteLink, to the changeUserPassword action? Any help would be appreciated :) Here is my complete code: UserList.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Security.MembershipUserCollection>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> UserList </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>UserList</h2> <table> <tr> <th>User Name</th> <th>Last Activity date</th> <th>Locked Out</th> </tr> <%foreach (MembershipUser user in Model){ %> <tr> <td><%: Html.RouteLink(user.UserName, "AdminPassword", new { controller="StoreManager", action="changeUserPassword", username = user.UserName }) %></td> <td><%: user.LastActivityDate %></td> <td><%: user.IsLockedOut %></td> </tr> <% }%> </table> </asp:Content> changeUserPassword.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<musicStoreMVC.ViewModels.ResetPasswordAdmin>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> changeUserPassword </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Change Password: <%: ViewData["username"] %></h2> <% using (Html.BeginForm()) {%> <%: Html.ValidationSummary(true) %> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%: Html.Hidden("username",ViewData["username"]) %> <%: Html.LabelFor(model => model.password) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.password) %> <%: Html.ValidationMessageFor(model => model.password) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.confirmPassword) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.confirmPassword) %> <%: Html.ValidationMessageFor(model => model.confirmPassword) %> </div> <p> <input type="submit" value="Create" /> </p> </fieldset> <% } %> <div> <%: Html.ActionLink("Back to List", "Index") %> </div> </asp:Content> My actions public ActionResult UserList() { var users = Membership.GetAllUsers(); return View(users); } public ActionResult changeUserPassword(string username) { ViewData["username"] = username; return View(); }

    Read the article

  • SQL Server adding a record record manually to a view

    - by SelectDistinct
    I have a view which contains the data seen in the image below. The view is showing me how many working days are available in each month for the current financial year taking away any school/bank holidays. As the month of August has zero days available it has excluded this month from the view. As the total number of days available will always be zero for the month of August, then it seems acceptable to hardcode the SQL to always have 0 for August, and also an April-August record which will be the same as April-July. What would be the best way to add these 2 records, and where about in the code should it be placed see example of code layout: see link (answered question) for layout of code: SQL populate total working days per month minus bank holidays for current financial year

    Read the article

  • Newbie question attribute from associated table not showing up in index view

    - by Lauren
    Hi I know this is something simple I am doing wrong. I have three tables, installation, neighborhood, schools Installation: has_many :schools has_many :neighborhoods Neighborhood: has_many :installations has_many :schools Schools: belongs_to :installations belongs_to :neighborhoods I can't figure out how to show the name of the neighborhood the school is located in on the index view. I can get it to show on the show view once I have the school id. But on the index view I can't figure out what to put in the controller that will allow me to access the neighborhood name from the neighborhood_id that is in the School model. I am sure this is so easy and I am screwing up something stupid. HELP!

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >