+----------------------------+ | Dog | +----------------------------+ | + name : String | | + breed : String | | + age : int | +----------------------------+ | + Dog(name: String, breed: | | String, age: int) | | + toString( ) : String | +----------------------------+On the layout, include 3 buttons, each of which adds specific Dog data to the arraylist. Also include a button that displays the list of dogs in the arraylist in a textview widget. Save the arraylist in a bundle that can be used to restore the arraylist when the app is destroyed due to being rotated.
77 = 64 + 8 + 4 + 1 = 0*27+1*26+0*25+0*24+1*23+1*22+0*21+1*20 = 01001101 binary
4d hex = 0100 1101 = 01001101 binary.
rv.setText("\u03B1, \u03B2, \u03B3");
Greek letters: αβγUse the ASCII Table and Hex Digits Table.
Minimum Maximum Byte 1 Byte 2 Byte 3 code code point point One byte: U+0000 U+007F 0xxxxxxx Two bytes: U+0080 U+07FF 110xxxxx 10xxxxxx Three bytes: U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxxIn the Byte 1, Byte 2, and Byte 3 columns, x represents the binary bits of the Unicode encoding for the character; 0 and 1 represent the special UTF-8 encoding bits.
0 3 B 4 0000 0010 1011 0100
0000 0010 1011 0100 01010 110100
01010 110100 11001010 10110100
11001010 10110100 1100 1010 1011 0100 C A B 4
0 4 2 9 0000 0100 0010 1001
0000 0100 0010 1001 10000 101001
10000 101001 11010000 10101001
11010000 10101001 1101 0000 1010 1001 D 0 A 9
Minimum Maximum Byte 1 Byte 2 Byte 3 code code point point One byte: U+0000 U+007F 0xxxxxxx Two bytes: U+0080 U+07FF 110xxxxx 10xxxxxx Three bytes: U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxxAns: Look up the Unicode code for € on the unicode.org website. The hex code is 20AC. Since 0800 <= 20AC <= FFFF, we use the 3 byte representation:
(a) Translate to binary: 2 0 A C 0010 0000 1010 1100 (b) Group bits into groups of 4, 6, and 6 bits: 0010 0000 1010 1100 --> 0010 000010 101100 (c) Prepend the UTF-8 bits 1110, 10, and 10. 0010 000010 101100 --> 11100010 10000010 10101100 (d) Group into groups of 4 bits and translate back to hex: 11100010 10000010 10101100 --> 1110 0010 1000 0010 1010 1100 --> E282ACCheck your answer. Copy and paste the Euro character € into Notepad or another editor that supports Unicode. Then display the hex dump of the file by invoking powershell and then entering the command
Format-Hex filename.txtIf you are on a Mac, which runs Unix, use the octal dump with the hex flag:
od -x filename.txt
private String[ ] words = {"zero", "one", "two", "three", "four"};
LinearLayout layout = findViewById(R.id.linear_layout);
final TextView txtWord = new TextView(this); final Button btnNextWord = new Button(this);
txtWord.setText(words[wordIndex++]); btnNextWord.setText("NEXT WORD");
txtWord.setTextSize( TypedValue.COMPLEX_UNIT_SP, 24); btnNextWord.setTextSize( TypedValue.COMPLEX_UNIT_SP, 24);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(50, 50, 0, 0); txtWord.setLayoutParams(params); btnNextWord.setLayoutParams(params);
layout.addView(txtWord); layout.addView(btnNextWord);
// Add onClick listener to button. btnNextWord.setOnClickListener( new View.OnClickListener( ) { @Override public void onClick(View view) { txtWord.setText( words[(wordIndex++ % numWords)]); } });
@Override public void onDraw(Canvas c) { Paint p = new Paint( ); p.setColor(Color.RED); c.drawCircle(100, 120, 30, p); }
public MyView(Context context) { super(context); }
MyView mv = new MyView(this); LinearLayout layout = findViewById(R.id.layout); layout.addView(mv);