Note that there are some explanatory texts on larger screens.

plurals
  1. POHow Do I Pass The Package To RemoteView in Android?
    text
    copied!<p>Me Doing "edu.sju.BlackJack" Is not causing updates that are later called to occur. I reference the layout correctly and the calls that are supposed to update it are correct, so what do I put in for the package name?</p> <p>I should add that my package name according to the manifest is the above. This is the code I have now which currently doesn't update the screen (or i'm guessing change the value correctly).</p> <p>RemoteViews name = new RemoteViews("edu.sju.BlackJack", R.layout.play_screen);</p> <p>If that's not it.. would it then be this code?</p> <p>name.setTextViewText(R.id.Dealer_Total, "0");</p> <p>Dealer_Total is the id for the TextView that I want to change.. however again the Change is not occurring.</p> <p>Thanks in advance for any and all assistance.</p> <p>Here is the whole of my code that i'm talking about, first Playscreen.java</p> <pre><code>package edu.sju.BlackJack; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.widget.ImageView; import android.widget.RemoteViews; import android.widget.TextView; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import java.util.*; public class PlayScreen extends Activity implements OnClickListener { /** Called when the activity is first created. */ GameEngine Engine = new GameEngine(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.play_screen); TextView TextDealer = (TextView)findViewById(R.id.Dealer_Total); Engine.setView(TextDealer); //Set up click listeners for all the buttons View hitButton = findViewById(R.id.hit_button); hitButton.setOnClickListener(this); View standButton = findViewById(R.id.stand_button); standButton.setOnClickListener(this); //new preplay button (ML 10/24/10) View prePlayButton = findViewById(R.id.prePlay_button); prePlayButton.setOnClickListener(this); Thread thread = new Thread(Engine); thread.start(); } public void onClick(View v) { switch (v.getId()) { case R.id.prePlay_button: v.setVisibility(View.GONE); System.out.println("Working?"); Engine.setGameStart(1); break; case R.id.hit_button: Engine.gameHit(1); break; case R.id.stand_button: Engine.gameStand(1); break; } // More buttons go here (if any) ... } } </code></pre> <hr> <p><strong>Now here's the GameEngine Thread</strong> Not the Whole of it, just enough so you get the idea</p> <hr> <pre><code>package edu.sju.BlackJack; import java.util.Random; import android.widget.RemoteViews; import android.widget.TextView; public class GameEngine implements Runnable { static int playerCount = 0; //keep record of which cards to change for player when hit is selected static int dealerCount = 0; //keep record of which cards to change for dealer when dealer hits static int win = 0; //keeps record of wins (JV 10/01/10) static int lose = 0; //keeps record of loss (JV 10/01/10) static int hit = 0; //let's engine know if hit button was selected (0 means it has not) static int stand = 0; //let's engine know if stand button was selected (0 means it has not) static int playerTotal = 0; //tells player's total (JV 10/01/10) static int dealerTotal = 0; //tells dealer's total (JV 10/01/10) static int playerTurn = 0; //activates buttons so that they do actions when clicked (as it's players turn) static int startGame = 0; //starts the game when the start game button is pressed TextView TextDealer; RemoteViews name = new RemoteViews("edu.sju.BlackJack", R.layout.play_screen); public void run() { name.setTextViewText(R.id.Dealer_Total, "0"); //main(); } public void setView(TextView a) { TextDealer = a; } public void setGameStart(int i) { startGame = i; } public void gameHit(int i) { if(playerTurn == 1) hit = 1; } public void gameStand(int i) { if(playerTurn == 1) stand = 1; } public void main() {//Start Game Deck mainDeck = new Deck(); fillDeck(mainDeck); //TextView TextPlayer = (TextView)findViewById(R.id.Player_Total); //TextDealer.setText("" + dealerTotal); //TextPlayer.setText("" + playerTotal); while(true) { if(startGame == 1) { if(mainDeck.getList().size() &lt; 15){ mainDeck = emptyDeck(); fillDeck(mainDeck); } //RESET CARD VIEWS TO DEFAULT //RESET DEALERCARD AND PLAYERCARD TOTALS TO 0 dealerTotal = 0; playerTotal = 0; playerCount = 0; dealerCount = 0; //playHand(mainDeck); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload