问:
How to continue code on next line (code too long)
How do I continue code (record insertion) on the next line?  In the example below I tried using underscore to end a line, then & to begin the next due to suggestions online, but it still doesn't compile.  Any thoughts?

Code Line:

```<code>CurrentDb.Execute "INSERT INTO AIP&BOP (PlanTitle, FileLocation, YearsofData, AnnualImprovedCML, AIP1, AIP1BOP1, AIP2, AIP1BOP2, AIP3, AIP1BOP3, AIP4, AIP1BOP4, AIP5, AIP1BOP5, AIP6, AIP1BOP6, AIP7, AIP1BOP7, AIP8, AIP1BOP8, AIP9, AIP1BOP9, AIP10, AIP1BOP10, AIP11, AIP1BOP11, AIP12, AIP1BOP12, AIP13, AIP1BOP13, AIP14, AIP1BOP14, AIP15, AIP1BOP15, AIP16, AIP1BOP16, AIP17, AIP1BOP17, AIP18, AIP1BOP18, AIP19, AIP1BOP19, AIP20, AIP1BOP20, AIP21, AIP1BOP21, AIP22, AIP1BOP22, AIP23, AIP1BOP23, AIP24, AIP1BOP24) Values ('" & RWPSheetvalues(71) & "', '" & RWPSheetvalues(72) & "', '" & RWPSheetvalues(73) & "', '" & RWPSheetvalues(74) & "','" & RWPSheetvalues(1) & "','" & RWPSheetvalues(2) & "', '" & RWPSheetvalues(3) & "', '" & RWPSheetvalues(4) & "','" & RWPSheetvalues(5) & "','" & RWPSheetvalues(6) & "', '" & RWPSheetvalues(7) & "', '" & RWPSheetvalues(8) & "','" & RWPSheetvalues(9) & "', _
& '" & RWPSheetvalues(10) & "', '" & RWPSheetvalues(11) & "', '" & RWPSheetvalues(12) & "','" & RWPSheetvalues(13) & "','" & RWPSheetvalues(14) & "', '" & RWPSheetvalues(15) & "', '" & RWPSheetvalues(16) & "','" & RWPSheetvalues(17) & "','" & RWPSheetvalues(18) & "', '" & RWPSheetvalues(19) & "', '" & RWPSheetvalues(20) & "','" & RWPSheetvalues(21) & "','" & RWPSheetvalues(22) & "', '" & RWPSheetvalues(23) & "', '" & RWPSheetvalues(24) & "','" & RWPSheetvalues(25) & "','" & RWPSheetvalues(26) & "', '" & RWPSheetvalues(27) & "', '" & RWPSheetvalues(28) & "','" & RWPSheetvalues(29) & "','" & RWPSheetvalues(30) & "', '" & RWPSheetvalues(31) & "', '" & RWPSheetvalues(32) & "','" & RWPSheetvalues(33) & "','" & RWPSheetvalues(34) & "', '" & RWPSheetvalues(35) & "', '" & RWPSheetvalues(36) & "','" & RWPSheetvalues(37) & "','" & RWPSheetvalues(38) & "', '" & RWPSheetvalues(39) & "', '" & RWPSheetvalues(40) & "','" & RWPSheetvalues(41) & "', _
& '" & RWPSheetvalues(42) & "', '" & RWPSheetvalues(43) & "', '" & RWPSheetvalues(44) & "','" & RWPSheetvalues(45) & "','" & RWPSheetvalues(46) & "', '" & RWPSheetvalues(47) & "', '" & RWPSheetvalues(48) & "','" & RWPSheetvalues(49) & "','" & RWPSheetvalues(50) & "', '" & RWPSheetvalues(51) & "', '" & RWPSheetvalues(52) & "','" & RWPSheetvalues(53) & "','" & RWPSheetvalues(54) & "', '" & RWPSheetvalues(55) & "', '" & RWPSheetvalues(56) & "','" & RWPSheetvalues(57) & "','" & RWPSheetvalues(58) & "', '" & RWPSheetvalues(59) & "', '" & RWPSheetvalues(60) & "','" & RWPSheetvalues(61) & "','" & RWPSheetvalues(62) & "', '" & RWPSheetvalues(63) & "', '" & RWPSheetvalues(64) & "','" & RWPSheetvalues(65) & "','" & RWPSheetvalues(66) & "', '" & RWPSheetvalues(67) & "', '" & RWPSheetvalues(68) & "','" & RWPSheetvalues(69) & "','" & RWPSheetvalues(70) & "')"
</code>```

答:
Always have a "finished" string on each line:</p>

```<code>CurrentDb.Execute "INSERT INTO AIP&BOP (PlanTitle, FileLocation, YearsofData, AnnualImprovedCML, AIP1, AIP1BOP1, AIP2, AIP1BOP2, AIP3, AIP1BOP3, AIP4, AIP1BOP4, AIP5, AIP1BOP5, AIP6, AIP1BOP6, AIP7, AIP1BOP7, AIP8, AIP1BOP8, AIP9, AIP1BOP9, AIP10, AIP1BOP10, AIP11, AIP1BOP11, AIP12, AIP1BOP12, AIP13, AIP1BOP13, AIP14, AIP1BOP14, AIP15, AIP1BOP15, AIP16, AIP1BOP16, AIP17, AIP1BOP17, AIP18, AIP1BOP18, AIP19, AIP1BOP19, AIP20, AIP1BOP20, AIP21, AIP1BOP21, AIP22, AIP1BOP22, AIP23, AIP1BOP23, AIP24, AIP1BOP24) Values ('" & RWPSheetvalues(71) & "', '" & RWPSheetvalues(72) & "', '" & RWPSheetvalues(73) & "', '" & RWPSheetvalues(74) & "','" & RWPSheetvalues(1) & "','" & RWPSheetvalues(2) & "', '" & RWPSheetvalues(3) & "', '" & RWPSheetvalues(4) & "','" & RWPSheetvalues(5) & "','" & RWPSheetvalues(6) & "', '" & RWPSheetvalues(7) & "', '" & RWPSheetvalues(8) & "','" & RWPSheetvalues(9) & "'," _ &
"'" & RWPSheetvalues(10) & "', '" & RWPSheetvalues(11) & "', '" & RWPSheetvalues(12) & "','" & RWPSheetvalues(13) & "','" & RWPSheetvalues(14) & "', '" & RWPSheetvalues(15) & "', '" & RWPSheetvalues(16) & "','" & RWPSheetvalues(17) & "','" & RWPSheetvalues(18) & "', '" & RWPSheetvalues(19) & "', '" & RWPSheetvalues(20) & "','" & RWPSheetvalues(21) & "','" & RWPSheetvalues(22) & "', '" & RWPSheetvalues(23) & "', '" & RWPSheetvalues(24) & "','" & RWPSheetvalues(25) & "','" & RWPSheetvalues(26) & "', '" & RWPSheetvalues(27) & "', '" & RWPSheetvalues(28) & "','" & RWPSheetvalues(29) & "','" & RWPSheetvalues(30) & "', '" & RWPSheetvalues(31) & "', '" & RWPSheetvalues(32) & "','" & RWPSheetvalues(33) & "','" & RWPSheetvalues(34) & "', '" & RWPSheetvalues(35) & "', '" & RWPSheetvalues(36) & "','" & RWPSheetvalues(37) & "','" & RWPSheetvalues(38) & "', '" & RWPSheetvalues(39) & "', '" & RWPSheetvalues(40) & "','" & RWPSheetvalues(41) & "'," _ &
"'" & RWPSheetvalues(42) & "', '" & RWPSheetvalues(43) & "', '" & RWPSheetvalues(44) & "','" & RWPSheetvalues(45) & "','" & RWPSheetvalues(46) & "', '" & RWPSheetvalues(47) & "', '" & RWPSheetvalues(48) & "','" & RWPSheetvalues(49) & "','" & RWPSheetvalues(50) & "', '" & RWPSheetvalues(51) & "', '" & RWPSheetvalues(52) & "','" & RWPSheetvalues(53) & "','" & RWPSheetvalues(54) & "', '" & RWPSheetvalues(55) & "', '" & RWPSheetvalues(56) & "','" & RWPSheetvalues(57) & "','" & RWPSheetvalues(58) & "', '" & RWPSheetvalues(59) & "', '" & RWPSheetvalues(60) & "','" & RWPSheetvalues(61) & "','" & RWPSheetvalues(62) & "', '" & RWPSheetvalues(63) & "', '" & RWPSheetvalues(64) & "','" & RWPSheetvalues(65) & "','" & RWPSheetvalues(66) & "', '" & RWPSheetvalues(67) & "', '" & RWPSheetvalues(68) & "','" & RWPSheetvalues(69) & "','" & RWPSheetvalues(70) & "')"
</code>```

Body:
How do I continue code (record insertion) on the next line?  In the example below I tried using underscore to end a line, then & to begin the next due to suggestions online, but it still doesn't compile.  Any thoughts?

Code Line:

CurrentDb.Execute "INSERT INTO AIP&BOP (PlanTitle, FileLocation, YearsofData, AnnualImprovedCML, AIP1, AIP1BOP1, AIP2, AIP1BOP2, AIP3, AIP1BOP3, AIP4, AIP1BOP4, AIP5, AIP1BOP5, AIP6, AIP1BOP6, AIP7, AIP1BOP7, AIP8, AIP1BOP8, AIP9, AIP1BOP9, AIP10, AIP1BOP10, AIP11, AIP1BOP11, AIP12, AIP1BOP12, AIP13, AIP1BOP13, AIP14, AIP1BOP14, AIP15, AIP1BOP15, AIP16, AIP1BOP16, AIP17, AIP1BOP17, AIP18, AIP1BOP18, AIP19, AIP1BOP19, AIP20, AIP1BOP20, AIP21, AIP1BOP21, AIP22, AIP1BOP22, AIP23, AIP1BOP23, AIP24, AIP1BOP24) Values ('" & RWPSheetvalues(71) & "', '" & RWPSheetvalues(72) & "', '" & RWPSheetvalues(73) & "', '" & RWPSheetvalues(74) & "','" & RWPSheetvalues(1) & "','" & RWPSheetvalues(2) & "', '" & RWPSheetvalues(3) & "', '" & RWPSheetvalues(4) & "','" & RWPSheetvalues(5) & "','" & RWPSheetvalues(6) & "', '" & RWPSheetvalues(7) & "', '" & RWPSheetvalues(8) & "','" & RWPSheetvalues(9) & "', _
& '" & RWPSheetvalues(10) & "', '" & RWPSheetvalues(11) & "', '" & RWPSheetvalues(12) & "','" & RWPSheetvalues(13) & "','" & RWPSheetvalues(14) & "', '" & RWPSheetvalues(15) & "', '" & RWPSheetvalues(16) & "','" & RWPSheetvalues(17) & "','" & RWPSheetvalues(18) & "', '" & RWPSheetvalues(19) & "', '" & RWPSheetvalues(20) & "','" & RWPSheetvalues(21) & "','" & RWPSheetvalues(22) & "', '" & RWPSheetvalues(23) & "', '" & RWPSheetvalues(24) & "','" & RWPSheetvalues(25) & "','" & RWPSheetvalues(26) & "', '" & RWPSheetvalues(27) & "', '" & RWPSheetvalues(28) & "','" & RWPSheetvalues(29) & "','" & RWPSheetvalues(30) & "', '" & RWPSheetvalues(31) & "', '" & RWPSheetvalues(32) & "','" & RWPSheetvalues(33) & "','" & RWPSheetvalues(34) & "', '" & RWPSheetvalues(35) & "', '" & RWPSheetvalues(36) & "','" & RWPSheetvalues(37) & "','" & RWPSheetvalues(38) & "', '" & RWPSheetvalues(39) & "', '" & RWPSheetvalues(40) & "','" & RWPSheetvalues(41) & "', _
& '" & RWPSheetvalues(42) & "', '" & RWPSheetvalues(43) & "', '" & RWPSheetvalues(44) & "','" & RWPSheetvalues(45) & "','" & RWPSheetvalues(46) & "', '" & RWPSheetvalues(47) & "', '" & RWPSheetvalues(48) & "','" & RWPSheetvalues(49) & "','" & RWPSheetvalues(50) & "', '" & RWPSheetvalues(51) & "', '" & RWPSheetvalues(52) & "','" & RWPSheetvalues(53) & "','" & RWPSheetvalues(54) & "', '" & RWPSheetvalues(55) & "', '" & RWPSheetvalues(56) & "','" & RWPSheetvalues(57) & "','" & RWPSheetvalues(58) & "', '" & RWPSheetvalues(59) & "', '" & RWPSheetvalues(60) & "','" & RWPSheetvalues(61) & "','" & RWPSheetvalues(62) & "', '" & RWPSheetvalues(63) & "', '" & RWPSheetvalues(64) & "','" & RWPSheetvalues(65) & "','" & RWPSheetvalues(66) & "', '" & RWPSheetvalues(67) & "', '" & RWPSheetvalues(68) & "','" & RWPSheetvalues(69) & "','" & RWPSheetvalues(70) & "')"

Body:
Always have a "finished" string on each line:

CurrentDb.Execute "INSERT INTO AIP&BOP (PlanTitle, FileLocation, YearsofData, AnnualImprovedCML, AIP1, AIP1BOP1, AIP2, AIP1BOP2, AIP3, AIP1BOP3, AIP4, AIP1BOP4, AIP5, AIP1BOP5, AIP6, AIP1BOP6, AIP7, AIP1BOP7, AIP8, AIP1BOP8, AIP9, AIP1BOP9, AIP10, AIP1BOP10, AIP11, AIP1BOP11, AIP12, AIP1BOP12, AIP13, AIP1BOP13, AIP14, AIP1BOP14, AIP15, AIP1BOP15, AIP16, AIP1BOP16, AIP17, AIP1BOP17, AIP18, AIP1BOP18, AIP19, AIP1BOP19, AIP20, AIP1BOP20, AIP21, AIP1BOP21, AIP22, AIP1BOP22, AIP23, AIP1BOP23, AIP24, AIP1BOP24) Values ('" & RWPSheetvalues(71) & "', '" & RWPSheetvalues(72) & "', '" & RWPSheetvalues(73) & "', '" & RWPSheetvalues(74) & "','" & RWPSheetvalues(1) & "','" & RWPSheetvalues(2) & "', '" & RWPSheetvalues(3) & "', '" & RWPSheetvalues(4) & "','" & RWPSheetvalues(5) & "','" & RWPSheetvalues(6) & "', '" & RWPSheetvalues(7) & "', '" & RWPSheetvalues(8) & "','" & RWPSheetvalues(9) & "'," _ &
"'" & RWPSheetvalues(10) & "', '" & RWPSheetvalues(11) & "', '" & RWPSheetvalues(12) & "','" & RWPSheetvalues(13) & "','" & RWPSheetvalues(14) & "', '" & RWPSheetvalues(15) & "', '" & RWPSheetvalues(16) & "','" & RWPSheetvalues(17) & "','" & RWPSheetvalues(18) & "', '" & RWPSheetvalues(19) & "', '" & RWPSheetvalues(20) & "','" & RWPSheetvalues(21) & "','" & RWPSheetvalues(22) & "', '" & RWPSheetvalues(23) & "', '" & RWPSheetvalues(24) & "','" & RWPSheetvalues(25) & "','" & RWPSheetvalues(26) & "', '" & RWPSheetvalues(27) & "', '" & RWPSheetvalues(28) & "','" & RWPSheetvalues(29) & "','" & RWPSheetvalues(30) & "', '" & RWPSheetvalues(31) & "', '" & RWPSheetvalues(32) & "','" & RWPSheetvalues(33) & "','" & RWPSheetvalues(34) & "', '" & RWPSheetvalues(35) & "', '" & RWPSheetvalues(36) & "','" & RWPSheetvalues(37) & "','" & RWPSheetvalues(38) & "', '" & RWPSheetvalues(39) & "', '" & RWPSheetvalues(40) & "','" & RWPSheetvalues(41) & "'," _ &
"'" & RWPSheetvalues(42) & "', '" & RWPSheetvalues(43) & "', '" & RWPSheetvalues(44) & "','" & RWPSheetvalues(45) & "','" & RWPSheetvalues(46) & "', '" & RWPSheetvalues(47) & "', '" & RWPSheetvalues(48) & "','" & RWPSheetvalues(49) & "','" & RWPSheetvalues(50) & "', '" & RWPSheetvalues(51) & "', '" & RWPSheetvalues(52) & "','" & RWPSheetvalues(53) & "','" & RWPSheetvalues(54) & "', '" & RWPSheetvalues(55) & "', '" & RWPSheetvalues(56) & "','" & RWPSheetvalues(57) & "','" & RWPSheetvalues(58) & "', '" & RWPSheetvalues(59) & "', '" & RWPSheetvalues(60) & "','" & RWPSheetvalues(61) & "','" & RWPSheetvalues(62) & "', '" & RWPSheetvalues(63) & "', '" & RWPSheetvalues(64) & "','" & RWPSheetvalues(65) & "','" & RWPSheetvalues(66) & "', '" & RWPSheetvalues(67) & "', '" & RWPSheetvalues(68) & "','" & RWPSheetvalues(69) & "','" & RWPSheetvalues(70) & "')"


来源: stackexchange

问:
How to separate a list into two different lists ?(Python2.7)
My current data is in the format of :

```<code>[  1982,      1, 108108,   5568],
[  1982,      2,  64488,   2433],
...,
[  2007,    498,   4341,    395],
[  2007,    499,   4328,    274],
[  2007,    500,   4323,   -118]]
</code>```

I want to put all of the data that is from 1982 into one list, and all of the data that is from 2007 into another list.

How would I do this?

ContentLicense: CC BY-SA 3.0

Body:
My current data is in the format of :

[  1982,      1, 108108,   5568],
[  1982,      2,  64488,   2433],
...,
[  2007,    498,   4341,    395],
[  2007,    499,   4328,    274],
[  2007,    500,   4323,   -118]]

I want to put all of the data that is from 1982 into one list, and all of the data that is from 2007 into another list.

How would I do this?

Body:
>>> l = [[1982, 1, 108108, 5568], [ 1982, 2, 64488, 2433], [ 2007, 498, 4341, 395], [ 2007, 499, 4328, 274], [ 2007, 500, 4323, -118]]
>>>
>>> result = [[], []]
>>> for sub in l:
...     result[sub[0] == 2007].extend(sub[1:])
...
>>> result
[[1, 108108, 5568, 2, 64488, 2433], [498, 4341, 395, 499, 4328, 274, 500, 4323, -118]]

First list of result holds the values for 1982, second list holds the values for 2007. Solution assumes you dont' have other years.


问:
Apex report full text search unable to apply scoring
i'm having some trouble and I can't find a straight answer when searching online.
I am using oracle apex 5.1.3, im writing up some plsql for a report with full text search, but can't seem to apply score to it, i know im making a blonde mistake but i know the base query works.

This is my original query

```<code>SELECT VENUE_NAME, CITY, POSTCODE, score(1) + score(2) as score
FROM GAMEVENUE
WHERE
(
CONTAINS(VENUE_NAME, '$FUZZY(plymouth)', 1) > 0
OR CONTAINS(CITY, '$FUZZY(plymouth)', 2) > 0
OR CONTAINS(POSTCODE, 'plymouth') > 0
)
ORDER BY score DESC;
</code>```

This is where the problems lie, any help would be great.

Parsing returned query results in "ORA-06550: line 9, column 11: ORA-29908: missing primary invocation for ancillary operator". If you believe your query is syntactically correct, check the "Use Generic Column Names" checkbox below to proceed without parsing.

```<code>DECLARE

  l_query VARCHAR2 (4096);

BEGIN

  l_query := '
                select
                "VENUE_ID",
                "VENUE_NAME",
                "CITY",
                "VENUE_NO",
                "POSTCODE",
                dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                score(1) + score(2) as score
                 FROM   "GAMEVENUE" i';

  IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
    l_query := l_query||' '||'
    where
    (
 contains(VENUE_NAME, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 1'') > 0 or
 contains(CITY, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 2'') > 0 or
 contains(POSTCODE, '''|| v('P2_REPORT_SEARCH') ||''') > 0
    )
   ORDER BY score DESC';
  END IF;

  RETURN l_query;

END;
</code>```

答:
```<code>ORA-29908: missing primary invocation for ancillary operator
</code>```

means you are actually running a query like this:

```<code>select
            "VENUE_ID",
            "VENUE_NAME",
            "CITY",
            "VENUE_NO",
            "POSTCODE",
            dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
            score(1) + score(2) as score
             FROM   "GAMEVENUE" i
</code>```

In other words, you have missed out the WHERE clause, probably because of this IF statement:

```<code>IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
  l_query := l_query||' '||'
  where ...
</code>```

What you probably want to do is avoid calling score() if the where clause is not being added, e.g.

```<code>if v('P2_REPORT_SEARCH') is not null then
   l_selectscore := 'score(1) + score(2)';
else
   l_selectscore := 'null';
end if;

l_query := '
            select
            "VENUE_ID",
            "VENUE_NAME",
            "CITY",
            "VENUE_NO",
            "POSTCODE",
            dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
            ' || l_select_score || ' as score
             FROM   "GAMEVENUE" i';
</code>```

Body:
i'm having some trouble and I can't find a straight answer when searching online.
I am using oracle apex 5.1.3, im writing up some plsql for a report with full text search, but can't seem to apply score to it, i know im making a blonde mistake but i know the base query works.

This is my original query

SELECT VENUE_NAME, CITY, POSTCODE, score(1) + score(2) as score
FROM GAMEVENUE
WHERE
(
CONTAINS(VENUE_NAME, '$FUZZY(plymouth)', 1) > 0
OR CONTAINS(CITY, '$FUZZY(plymouth)', 2) > 0
OR CONTAINS(POSTCODE, 'plymouth') > 0
)
ORDER BY score DESC;

This is where the problems lie, any help would be great.

Parsing returned query results in "ORA-06550: line 9, column 11: ORA-29908: missing primary invocation for ancillary operator". If you believe your query is syntactically correct, check the "Use Generic Column Names" checkbox below to proceed without parsing.

DECLARE

  l_query VARCHAR2 (4096);

BEGIN

  l_query := '
                select
                "VENUE_ID",
                "VENUE_NAME",
                "CITY",
                "VENUE_NO",
                "POSTCODE",
                dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                score(1) + score(2) as score
                 FROM   "GAMEVENUE" i';

  IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
    l_query := l_query||' '||'
    where
    (
 contains(VENUE_NAME, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 1'') > 0 or
 contains(CITY, ''$fuzzy('|| v('P2_REPORT_SEARCH') ||'), 2'') > 0 or
 contains(POSTCODE, '''|| v('P2_REPORT_SEARCH') ||''') > 0
    )
   ORDER BY score DESC';
  END IF;

  RETURN l_query;

END;

Body:
ORA-29908: missing primary invocation for ancillary operator

means you are actually running a query like this:

select
            "VENUE_ID",
            "VENUE_NAME",
            "CITY",
            "VENUE_NO",
            "POSTCODE",
            dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
            score(1) + score(2) as score
             FROM   "GAMEVENUE" i

In other words, you have missed out the WHERE clause, probably because of this IF statement:

IF v('P2_REPORT_SEARCH') IS NOT NULL THEN
  l_query := l_query||' '||'
  where ...

What you probably want to do is avoid calling score() if the where clause is not being added, e.g.

if v('P2_REPORT_SEARCH') is not null then
   l_selectscore := 'score(1) + score(2)';
else
   l_selectscore := 'null';
end if;

l_query := '
            select
            "VENUE_ID",
            "VENUE_NAME",
            "CITY",
            "VENUE_NO",
            "POSTCODE",
            dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
            ' || l_select_score || ' as score
             FROM   "GAMEVENUE" i';


问:
Android ListView - onListItemClick does not work properly
I created a ListView in Android, and a corresponding ListActivity. Each individual item in the ListView has just one TextView (I plan to add an image and a CheckBox later).The ListActivity overrides the  onListItemClick to perform certain tasks on click of any item on the list.

Heres whats happening -

When I first tried clicking on any item, nothing happened.

I then tried setting the properties "Focusable" and "Focusable in Touch Mode" to false for the TextView, as mentioned here, here and here. The List items started recognizing clicks, but only when I clicked somewhere away from the TextView. Whenever I tried clicking on the TextView or anywhere near it, it did not work.

I also tried changing various attributes like Clickable, but nothing has worked so far.

Any idea what I could be doing wrong ?

Thanks

答: Class which will listen clicks on ListView should implement interface  AdapterView.OnItemClickListener

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 4.0


问:
How to use files with .save extension
I have my Laravel site running on apache2 server. Also I use php 7.1, git, composer and sometimes I use nano to change files on the server. In app/Http/Controllers/ I found file UploadsController.php.save which is similar to UploadsController.php but have some changes. Could somebody explain how I should use this file and how it has been created?

答:
.save files are recovery files that Nano creates when its buffer is dumped. If your Uploadsontroller.php file looks OK, you can just delete Uploadsontroller.php.save.

You should also probably add *.save to your gitignore file so these files don't clatter up your git status results.

Title: How to use files with .save extension


问:
RecyclerView animation when clearing whole adapter and adding new elements
So imagine that at first we load 10 items in our RecyclerView. Adding or removing one element gives us a nice animation (the adapter has stable ids).

The problem is, I have a search bar, I can look for something and then the result should replace the current items of the RecyclerView. If some item was already there, there is a nice "moving" animation. But if all items are new, there is a quite ugly fade-in transition that it's too fast and looks like a glitch. Is it possible to override that animation? I'd like to have a fade-out-fade-in one but slower.

By the way, when the query returns with results, I do this in the adapter:

```<code>mItems.clear();
mItems.addAll(resultItems);
notifyDataSetChanged();
</code>```

Also, it's worth to say that if I make a search with no results, then I see the RecyclerView empty and then if I get some results again, the transition from empty state to some results looks ok.

答:
If you do range methods like RangeRemoved/RangeAdded, you loose out in the animation side. So, do it one by one in a loop to preserve the animation effect of one by one, including a delay in the loop. Here's how I have implemented:

MainActivity.java

```<code>clearItemsView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final List<LineItem> lineItemsCopy = new ArrayList<>(lineItems);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i=0; i<lineItemsCopy.size(); i++) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                salesOrderItemListAdapter.removeItem(0);
                            }
                        });
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();
            Snackbar snackbar = Snackbar.make(coordinatorLayout, getString(R.string.items_cleared_message), Snackbar.LENGTH_LONG)
                    .setAction(getString(R.string.label_undo), new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    for (int i=0; i<lineItemsCopy.size(); i++) {
                                        final int finalI = i;
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                salesOrderItemListAdapter.restoreItem(lineItemsCopy.get(finalI), 0);
                                            }
                                        });
                                        try {
                                            Thread.sleep(500);
                                        } catch (InterruptedException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }
                            }).start();
                        }
                    }).setActionTextColor(Color.YELLOW);
            snackbar.show();
        }
    });
</code>```

RecyclerViewAdapter.java

```<code>    //Only remove & restore functions are shown
    public void removeItem(int position) {
        lineItems.remove(position);
        notifyItemRemoved(position);
    }

    public void restoreItem(LineItem item, int position) {
        lineItems.add(position, item);
        notifyItemInserted(position);
    }
</code>```

Body:
So imagine that at first we load 10 items in our RecyclerView. Adding or removing one element gives us a nice animation (the adapter has stable ids).

The problem is, I have a search bar, I can look for something and then the result should replace the current items of the RecyclerView. If some item was already there, there is a nice "moving" animation. But if all items are new, there is a quite ugly fade-in transition that it's too fast and looks like a glitch. Is it possible to override that animation? I'd like to have a fade-out-fade-in one but slower.

By the way, when the query returns with results, I do this in the adapter:

mItems.clear();
mItems.addAll(resultItems);
notifyDataSetChanged();

Also, it's worth to say that if I make a search with no results, then I see the RecyclerView empty and then if I get some results again, the transition from empty state to some results looks ok.

Body:
If you do range methods like RangeRemoved/RangeAdded, you loose out in the animation side. So, do it one by one in a loop to preserve the animation effect of one by one, including a delay in the loop. Here's how I have implemented:

MainActivity.java

clearItemsView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final List<LineItem> lineItemsCopy = new ArrayList<>(lineItems);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i=0; i<lineItemsCopy.size(); i++) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                salesOrderItemListAdapter.removeItem(0);
                            }
                        });
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();
            Snackbar snackbar = Snackbar.make(coordinatorLayout, getString(R.string.items_cleared_message), Snackbar.LENGTH_LONG)
                    .setAction(getString(R.string.label_undo), new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    for (int i=0; i<lineItemsCopy.size(); i++) {
                                        final int finalI = i;
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                salesOrderItemListAdapter.restoreItem(lineItemsCopy.get(finalI), 0);
                                            }
                                        });
                                        try {
                                            Thread.sleep(500);
                                        } catch (InterruptedException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }
                            }).start();
                        }
                    }).setActionTextColor(Color.YELLOW);
            snackbar.show();
        }
    });

RecyclerViewAdapter.java

    //Only remove & restore functions are shown
    public void removeItem(int position) {
        lineItems.remove(position);
        notifyItemRemoved(position);
    }

    public void restoreItem(LineItem item, int position) {
        lineItems.add(position, item);
        notifyItemInserted(position);
    }


问:
Can I search for multiple strings in one "find" command in batch script?
I have a windows batch script that will look for a string within a file

```<code>find /i "WD6"  %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff
</code>```

Currently this is what my code looks like. I've come across a new string I want to search for in the same file and do the same action if it finds it, it stored it in a variable called %acctg_cyc% can I search for both strings in one line of code? I tried this:

```<code>find /i "WD6" %acctg_cyc%  %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff
</code>```

But it seems to ignore the %acctg_cyc% and only look for "WD6" in file.txt. I tried testing where %acctg_cyc% is in file.txt and when it is not and it passes both times.

Any thoughts? I know I could do this in more lines of code but I'm really trying to avoid that right now. Maybe it's just not possible.

Thank you for any help!

答:
I tried findstr with multiple /C: arguments (one for each to be searched sentence) which did the trick in my case.
So this is my solution for finding multiple sentences in one file and redirect the output:

```<code>findstr /C:"the first search" /C:" a second search " /C:"and another" sourcefile.txt > results.txt
</code>```

Body:
I have a windows batch script that will look for a string within a file

find /i "WD6"  %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff

Currently this is what my code looks like. I've come across a new string I want to search for in the same file and do the same action if it finds it, it stored it in a variable called %acctg_cyc% can I search for both strings in one line of code? I tried this:

find /i "WD6" %acctg_cyc%  %Inputpath%file.txt
if %errorlevel% == 0 GOTO somestuff

But it seems to ignore the %acctg_cyc% and only look for "WD6" in file.txt. I tried testing where %acctg_cyc% is in file.txt and when it is not and it passes both times.

Any thoughts? I know I could do this in more lines of code but I'm really trying to avoid that right now. Maybe it's just not possible.

Thank you for any help!

Body:
I tried findstr with multiple /C: arguments (one for each to be searched sentence) which did the trick in my case.
So this is my solution for finding multiple sentences in one file and redirect the output:

findstr /C:"the first search" /C:" a second search " /C:"and another" sourcefile.txt > results.txt


问:
How to pass string to a makefile from shell script?
I tried in the following way

In shell script :

```<code>Var='abc xyz' make one myvar=$Var
</code>```

But when it goes into makefile it is just showing myvar as abc but it is not taking abc xyz as my input

答:
Var='abc xyz' make one myvar=$Var

First of all, when expanding the Var variable in the line above, you may be expanding an undefined variable (i.e.: Var). What the line above is doing is just passing an environment variable called Var with that value to the process which is going to run make.

For the same reason, the following line may not print "Hello World" unless Var was previously defined with that value:

```<code>Var='Hello World' echo $Var
</code>```

The following line will however display "Hello World":

```<code>Var='Hello World'; echo $Var
</code>```

$Var in those examples above is being expanded by the shell. The process running echo receives the Var variable, not the shell.

Back to the main problem

But when it goes into makefile it is just showing myvar as abc but it is not taking abc xyz as my input

The line

```<code>Var='abc xyz'; make one myvar=$Var
</code>```

is being expanded by the shell as:

```<code>Var='abc xyz'; make one myvar=abc xyz
</code>```

The space above is used as separator for command-line arguments, so the process running make is actually receiving two arguments instead of one in place of the command-line variable:

myvar=abc

xyz

Solution

You need to scape the space, so that it won't be interpreted as an argument separator by the shell. You can achieve that by placing double quotes around $Var:

```<code>Var='abc xyz'; make one myvar="$Var"
</code>```

This way, the process running make will receive a single argument for the command-line variable: myvar=abc xyz.

Body:
I tried in the following way

In shell script :

Var='abc xyz' make one myvar=$Var

But when it goes into makefile it is just showing myvar as abc but it is not taking abc xyz as my input

Body:
Var='abc xyz' make one myvar=$Var

First of all, when expanding the Var variable in the line above, you may be expanding an undefined variable (i.e.: Var). What the line above is doing is just passing an environment variable called Var with that value to the process which is going to run make.

For the same reason, the following line may not print "Hello World" unless Var was previously defined with that value:

Var='Hello World' echo $Var

The following line will however display "Hello World":

Var='Hello World'; echo $Var

$Var in those examples above is being expanded by the shell. The process running echo receives the Var variable, not the shell.

Back to the main problem

But when it goes into makefile it is just showing myvar as abc but it is not taking abc xyz as my input

The line

Var='abc xyz'; make one myvar=$Var

is being expanded by the shell as:

Var='abc xyz'; make one myvar=abc xyz

The space above is used as separator for command-line arguments, so the process running make is actually receiving two arguments instead of one in place of the command-line variable:

myvar=abc

xyz

Solution

You need to scape the space, so that it won't be interpreted as an argument separator by the shell. You can achieve that by placing double quotes around $Var:

Var='abc xyz'; make one myvar="$Var"

This way, the process running make will receive a single argument for the command-line variable: myvar=abc xyz.


问:
Parent and child dimension calculations
Can someone help me understand why #child is not the same size as #parent?</p>

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Title</title>
    </head>
    <body>
        <div id='parent' style='border: 1px solid black'>
            <div id='child' style='background-color: #888888'>
                <p>Here is some content</p>
                <div id='grandchild' style='margin-bottom: 1em'>
                    <p>A little more content</p>
                </div>
            </div>
        </div>
    </body>
</html>
</code>```

答:
Here's what's going on:

Margin Collapsing. Jeroen's answer pointed me to the W3C box model specs for collapsing margins, which gave me a headache, and didn't quite answer the question of the border (which Oded first pointed out). Then I found this article and pieced the solution together (I'm talking about just the top margins, but this exact same solution applies to the bottom margins).

When two [block-level] elements' vertical margins are touching, the larger margin is used and the smaller margin is discarded.

Everything in your code is considered a block-level element, including the  and  tags.

The  has a default margin-top of 8px inside its parent  element.

The first
 tag has a default margin-top of 16px.

Margin collapsing isn't confined to siblings, so the
 tag starts to check against its parent tag's position and margins.

The #child element has a margin-top of 0. The
 top margin is touching the #child top margin, so they collapse to a single 16px margin (16 > 0). The
 tag's 16px margin "pushes through" and acts as a margin for the #child tag.

The 16px margin from
 is still checking for margins directly above it. Next up would be the #parent tag, which also has a margin-top of 0.

BUT, The 1px border on #parent prevents
 from going any further.
 isn't going to run into any more margins above it, because it's touching the 1px border. So the collapsing stops inside the top border of #parent.

The 16px top-margin is rendered, and underneath is the #child tag whose 0px margin was collapsed.

That's why the #parent box is 32px taller than the #child box: The
 margins "crashed through" until they hit something that wasn't a margin (the 1px border). So, what happens if the 1px border on #parent hadn't been there to stop the collapsing?

Follow steps 1-7 above.

 's top margin runs into the #parent element's 0px top margin. Again,
 is the bigger margin (16 vs 0), so the collapsing continues upward.

 's top margin hits the  tag. The  has a default top margin of 8px. The
 tag is bigger, so now the  tag has "inherited" the 16px top margin, and the 8px is discarded.

The
 top margin reaches the  tag. Since  is the root element, the collapsing stops here. The  tag renders with a 16px top margin, and the #parent, #child, and
 elements all render beneath;
 is snug inside the #parent box because the margin crashed through it.

The reason why this took me so long to figure out is the same reason I hadn't heard of collapsing margins until today: Firebug doesn't clearly depict collapsing margins. In Firebug, the
 tag still shows that it's holding the 16px top margin. This is true. However, there's no indication that any collapsing has taken place--the  tag still reports an 8px top border, even though it's been discarded.

I'm glad I know this now; it clarifies much confusion I've had about page layouts.

Edit:

The article I referenced is really worth the read. Not only did it give me the info I needed for the answer, it also details how in IE7, the  tag doesn't participate in border collapsing. That explains a lot.

Title: Parent and child dimension calculations

Body:
Can someone help me understand why #child is not the same size as #parent?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

        <title>Title</title>

Here is some content

A little more content

Body:
Here's what's going on:

Margin Collapsing. Jeroen's answer pointed me to the W3C box model specs for collapsing margins, which gave me a headache, and didn't quite answer the question of the border (which Oded first pointed out). Then I found this article and pieced the solution together (I'm talking about just the top margins, but this exact same solution applies to the bottom margins).

When two [block-level] elements' vertical margins are touching, the larger margin is used and the smaller margin is discarded.

Everything in your code is considered a block-level element, including the <html> and <body> tags.

The <body> has a default margin-top of 8px inside its parent <html> element.

The first <p> tag has a default margin-top of 16px.

Margin collapsing isn't confined to siblings, so the <p> tag starts to check against its parent tag's position and margins.

The #child element has a margin-top of 0. The <p> top margin is touching the #child top margin, so they collapse to a single 16px margin (16 > 0). The <p> tag's 16px margin "pushes through" and acts as a margin for the #child tag.

The 16px margin from <p> is still checking for margins directly above it. Next up would be the #parent tag, which also has a margin-top of 0.

BUT, The 1px border on #parent prevents <p> from going any further. <p> isn't going to run into any more margins above it, because it's touching the 1px border. So the collapsing stops inside the top border of #parent.

The 16px top-margin is rendered, and underneath is the #child tag whose 0px margin was collapsed.

That's why the #parent box is 32px taller than the #child box: The <p> margins "crashed through" until they hit something that wasn't a margin (the 1px border). So, what happens if the 1px border on #parent hadn't been there to stop the collapsing?

Follow steps 1-7 above.

<p> 's top margin runs into the #parent element's 0px top margin. Again, <p> is the bigger margin (16 vs 0), so the collapsing continues upward.

<p> 's top margin hits the <body> tag. The <body> has a default top margin of 8px. The <p> tag is bigger, so now the <body> tag has "inherited" the 16px top margin, and the 8px is discarded.

The <p> top margin reaches the <html> tag. Since <html> is the root element, the collapsing stops here. The <body> tag renders with a 16px top margin, and the #parent, #child, and <p> elements all render beneath; <p> is snug inside the #parent box because the margin crashed through it.

The reason why this took me so long to figure out is the same reason I hadn't heard of collapsing margins until today: Firebug doesn't clearly depict collapsing margins. In Firebug, the <p> tag still shows that it's holding the 16px top margin. This is true. However, there's no indication that any collapsing has taken place--the <body> tag still reports an 8px top border, even though it's been discarded.

I'm glad I know this now; it clarifies much confusion I've had about page layouts.

Edit:

The article I referenced is really worth the read. Not only did it give me the info I needed for the answer, it also details how in IE7, the <body> tag doesn't participate in border collapsing. That explains a lot.


问:
how to send details to mail in javascript code
I want to send all input data which filled in the contact form.

contact form in javascript

```<code>function sendMail() {
    $.ajax({
      type: 'POST',
      url: 'https://mandrillapp.com/api/1.0/messages/send.json',
      data: {
        'key': 'YOUR API KEY HERE',
        'message': {
          'from_email': 'YOUR@EMAIL.HERE',
          'to': [
              {
                'email': 'RECIPIENT@EMAIL.HERE',
                'name': 'RECIPIENT NAME (OPTIONAL)',
                'type': 'to'
              }
            ],
          'autotext': 'true',
          'subject': 'YOUR SUBJECT HERE!',
          'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
        }
      }
     }).done(function(response) {
       console.log(response); // if you're into that sorta thing
     });
}
</code>```

答:
After reading your query, I persume a solution

```<code>$.ajax({
    url: 'https://mandrillapp.com/api/1.0/messages/send.json',
    type: 'POST',
    data: {
    'key': <your_key>,
    'form-data': form.serialize()
    }
 })
</code>```

Your will get all the keyword of input name with value inside the form-data dictionary.

Body:
I want to send all input data which filled in the contact form.

contact form in javascript

function sendMail() {
    $.ajax({
      type: 'POST',
      url: 'https://mandrillapp.com/api/1.0/messages/send.json',
      data: {
        'key': 'YOUR API KEY HERE',
        'message': {
          'from_email': 'YOUR@EMAIL.HERE',
          'to': [
              {
                'email': 'RECIPIENT@EMAIL.HERE',
                'name': 'RECIPIENT NAME (OPTIONAL)',
                'type': 'to'
              }
            ],
          'autotext': 'true',
          'subject': 'YOUR SUBJECT HERE!',
          'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
        }
      }
     }).done(function(response) {
       console.log(response); // if you're into that sorta thing
     });
}

Body:
After reading your query, I persume a solution

$.ajax({
    url: 'https://mandrillapp.com/api/1.0/messages/send.json',
    type: 'POST',
    data: {
    'key': <your_key>,
    'form-data': form.serialize()
    }
 })

Your will get all the keyword of input name with value inside the form-data dictionary.


问:
Getting error when running the app android.content.res.Resources$NotFoundException: String resource ID #0x0
I am developing a quiz app when i run this app i am getting error android.content.res.Resources$NotFoundException: String resource ID #0x0 after changing the minimum sdk from 16 to 19.Please help me run this app

Here is my activity_main.xml file

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.awwalsoft.javaplay.MainActivity">

    <LinearLayout
        android:id="@+id/data_list"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_weight="3"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view1"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:onClick="startGame"
                android:layout_height="match_parent">

                <LinearLayout

                    android:layout_width="match_parent"
                    android:orientation="vertical"
                    android:layout_height="match_parent">

                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/play"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/start"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view1_1"
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:background="@drawable/scoreboard"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:id="@+id/highscore"
                        android:gravity="center"
                        android:textSize="@dimen/textsizebutton"
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:layout_weight="2"/>

                    <TextView
                        android:text="@string/highscore"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

        </LinearLayout>

        <TextView
            android:text="@string/useapps"
            android:layout_marginTop="@dimen/eightdpmargin"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="@dimen/sptextsize2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_weight="3"
            android:layout_marginTop="@dimen/eightdpmargin"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="horizontal">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2"
                android:layout_width="@dimen/minhigh"
                android:onClick="javaBasicsLearningApp"
                android:layout_marginEnd="@dimen/cardviewmarginright"
                android:layout_height="match_parent">

                <LinearLayout

                    android:layout_width="match_parent"
                    android:orientation="vertical"
                    android:layout_height="match_parent">

                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jbl"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/jbl"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2_1"
                android:layout_width="@dimen/minhigh"
                android:onClick="javaDeepLearningApp"
                android:layout_marginEnd="@dimen/eightdpmargin"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jdl"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/jdl"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2_2"
                android:layout_width="@dimen/minhigh"
                android:onClick="learnJdbcApp"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jdbc"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/ljdbc"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

                </LinearLayout>

            </HorizontalScrollView>

        </LinearLayout>

        <LinearLayout
            android:layout_marginTop="@dimen/eightdpmargin"
            android:layout_weight="2"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view3"
                android:onClick="helpClick"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/help"
                        android:layout_width="0dp"
                        android:layout_margin="@dimen/sixteendppadding"
                        android:layout_height="match_parent"
                        android:layout_weight="1"/>
                    <TextView
                        android:text="@string/help"
                        android:gravity="center"
                        android:id="@+id/helptext"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/textsizemain"
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

        </LinearLayout>

    </LinearLayout>

  </LinearLayout>
</code>```

here is my MainActivity.java file

```<code>package com.awwalsoft.javaplay;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    String moreApps1 = "com.awwalsoft.javabasicslearning";
    String moreApps2 = "com.awwalsoft.javadeeplearning";
    String moreApps3 = "com.awwalsoft.learnjdbc";
    private Player currentPlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        currentPlayer = ((JavaPlay) getApplication()).player; //gets player from lightquiz application
        updateHighScore();

    }

    public void javaBasicsLearningApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps1)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps1)));
        }

    }

    public void javaDeepLearningApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps2)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps2)));
        }

    }

    public void learnJdbcApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps3)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps3)));
        }

    }

    public void helpClick(View view){
        Intent helpIntent = new Intent(this,Help.class);
        startActivity(helpIntent);
    }

    @Override
    public void onResume() {
        super.onResume();
        ((JavaPlay) this.getApplicationContext()).clearQuestions();
        updateHighScore();
    }
    @Override
    public void onBackPressed() {
        this.finish();
    }

    public void startGame(View view) {

                Intent intent = new Intent(this, PlayGame.class);
                startActivity(intent);

    }

    void selecGenre() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.dialog_title);
        String[] genres = QuestionGenre.names();
        builder.setItems(QuestionGenre.names(), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                beginQuizGame(QuestionGenre.names()[which]);
            }
        });

        AlertDialog dialog = builder.create();
        dialog.show();
    }

    void beginQuizGame(String genre) {
        Intent intent = new Intent(this, PlayGame.class);
        intent.putExtra("Genre", genre);
        startActivity(intent);

    }

    private void updateHighScore() {
        TextView highScoreText = (TextView) findViewById(R.id.highscore);
        highScoreText.setText(currentPlayer.getHighScore());
    }

}
</code>```

here is my PlayGame.java file

```<code>package com.awwalsoft.javaplay;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;

public class PlayGame extends AppCompatActivity {
    private final int questionsDelay = 500;
    private final int questionsPoints = 10;
    private final int questionSeconds = 8;
    private int points;
    private int lives;
    private int correctAnswer;
    //Layout Stuff
    private ImageView correctImg;
    private ImageView wrongImg;
    private ImageView questionImg;
    private TextView questionText;
    private Button soundButton;
    private TextView pointsText;
    private TextView lifeText;
    private TextView countdownText;
    private Button[] answerButtons = new Button[4];

    private CountDownTimer countdown;
    private QuestionsGenerator generator;
    private ProgressDialog progress;

    private String genreSelection = null;
    private boolean gameFinished = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_game);

        Intent intent = getIntent();
        genreSelection = intent.getStringExtra("Genre");

        progress = new ProgressDialog(this);
        progress.setMessage("Loading Database ");
        progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progress.setIndeterminate(true);
        progress.show();

        new Thread(new Runnable() {
            public void run() {
                try {
                    loadQuestions();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                loadLayout();

                runOnUiThread(new Runnable() {
                    public void run() {
                        startGame();
                    }
                });
            }
        }).start();
    }

    @Override
    public void onPause() {
        super.onPause();
        countdown.cancel();
        hideQuestionMultimedia();
        this.finish();
        gameFinished = true;
        // gameOver();

    }

    @Override
    public void onBackPressed() {
        // this.finish();
        gameOver();
    }

    //an answer was clicked
    public void answerClicked(View view) {
        countdown.cancel();
        int answer; //-1 by default
        buttonsActive(false);
        switch (view.getId()) {
            case R.id.answer_1:
                answer = 1;
                break;
            case R.id.answer_2:
                answer = 2;
                break;
            case R.id.answer_3:
                answer = 3;
                break;
            case R.id.answer_4:
                answer = 4;
                break;
            default:
                throw new RuntimeException("Unknown button ID");
        }
        if (correctAnswer == answer) correctAnswer();
        else wrongAnswer();
        updateTexts();
        nextQuestion();
    }

    public void soundClick(View view) {
        switch (view.getId()) {
            case R.id.sound_button:
                playSound();
                break;
            default:
                throw new RuntimeException("Unknown button ID");

        }
    }

    //set a new question from generator

    private void playSound() {
        if (!gameFinished)
            ((JavaPlay) this.getApplicationContext()).soundHandler.playQuestionSound();
    }

    private void setQuestion() {
        if (!gameFinished) {
            hideQuestionMultimedia();
            buttonsActive(true);
            Question quest = generator.getQuestion();//get a randomized question

            if (!quest.isValid()) throw new RuntimeException("Invalid Question");
            this.correctAnswer = quest.getCorrectAnswer();
            for (int i = 0; i < 4; i++)
                answerButtons[i].setText(quest.getAnswer(i)); //set questions layout

            hideAnswerImage();
            questionText.setText(quest.getText());
            QuestionType qt = quest.type();
            switch (qt) {
                case TEXT:
                    //showQuestionText(((TextQuestion) quest).text);
                    break;
                case IMAGE:
                    showQuestionImage(((ImageQuestion) quest).image);
                    break;
                case SOUND:
                    showQuestionSound(((SoundQuestion) quest).sound);
                    playSound();
                    break;
                default:
                    throw new RuntimeException("Invalid question type");
            }
            countdown = new CountDownTimer(questionSeconds * 1000, 500) {
                @Override
                public void onTick(long millisUntilFinished) {
                    countdownText.setText(Integer.toString((int) (millisUntilFinished / 1000) + 1));
            /* if(millisUntilFinished/1000 == 1) {
                 wrongAnswer();
                 updateTexts();
                 nextQuestion();
             }*/
                }

                @Override
                public void onFinish() {
                    buttonsActive(false);
                    wrongAnswer();
                    updateTexts();
                    nextQuestion();
                }
            }.start();
        }
    }

    private void showQuestionSound(String sound) {
        soundButton.setVisibility(View.VISIBLE);
        soundButton.setClickable(true);
        ((JavaPlay) this.getApplicationContext()).soundHandler.setQuestionSound(sound);
    }

    private void showQuestionImage(String imagename) {
        int resourceId = this.getResources().getIdentifier(imagename, "drawable", this.getPackageName());
        questionImg.setImageResource(resourceId);
        questionImg.setVisibility(View.VISIBLE);
        //questionImg.setMaxHeight();
    }

    private void hideQuestionMultimedia() {
        questionImg.setVisibility(View.INVISIBLE);
        soundButton.setVisibility(View.INVISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.stopQuestionSound();
        soundButton.setClickable(false);
    }
    //next question after som time
    private void nextQuestion() {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (generator.size() == 0) gameOver(); //no more questions left
                else setQuestion();
            }
        }, questionsDelay);
    }

    //What happens when a correct answer was clicked
    private void correctAnswer() {
        points += questionsPoints;
        wrongImg.setVisibility(View.INVISIBLE);
        correctImg.setVisibility(View.VISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.playCorrectSound();
    }

    //What happens when a wrong answer was clicked
    private void wrongAnswer() {
        correctImg.setVisibility(View.INVISIBLE);
        wrongImg.setVisibility(View.VISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.playWrongSound();
        lives--;
        if (lives == 0) gameOver();
    }

    //Hides any answer image (tick or cross)
    private void hideAnswerImage() {
        correctImg.setVisibility(View.INVISIBLE);
        wrongImg.setVisibility(View.INVISIBLE);
    }

    private void buttonsActive(boolean b) {
        for (Button button : answerButtons) {
            button.setClickable(b);
        }
    }

    private void loadLayout() {
        correctImg = (ImageView) findViewById(R.id.correct_img);
        wrongImg = (ImageView) findViewById(R.id.wrong_img);
        pointsText = (TextView) findViewById(R.id.points_text);
        lifeText = (TextView) findViewById(R.id.life_text);
        countdownText = (TextView) findViewById(R.id.countdown_text);
        questionImg = (ImageView) findViewById(R.id.question_image);
        questionText = (TextView) findViewById(R.id.question);
        soundButton = (Button) findViewById(R.id.sound_button);

        answerButtons[0] = (Button) findViewById(R.id.answer_1);
        answerButtons[1] = (Button) findViewById(R.id.answer_2);
        answerButtons[2] = (Button) findViewById(R.id.answer_3);
        answerButtons[3] = (Button) findViewById(R.id.answer_4);

        hideAnswerImage();
    }

    //Updates life and score texts
    private void updateTexts() {
        lifeText.setText("Life:" + lives);
        pointsText.setText("Score:" + points);
        countdownText.setText("");
    }

    private void gameOver() {
        //hideQuestionMultimedia();
        gameFinished = true;
        ((JavaPlay) this.getApplicationContext()).soundHandler.stopQuestionSound();
        soundButton.setClickable(false);
        countdown.cancel();
        buttonsActive(false);
        Intent intent = new Intent(this, GameOver.class);
        intent.putExtra("Score", points);
        startActivity(intent);
        this.finish();
    }

    //reloads questions from xml (old)
   /* private void reload_questions() throws IOException, XmlPullParserException {
        XmlResourceParser xmlq = getResources().getXml(R.xml.questions);
        MainActivity.generator.loadQuestions(xmlq);
        xmlq.close();
    }*/

    //Starts game
    private void startGame() {
        points = 0;
        lives = 3;
        gameFinished = false;
        buttonsActive(true);
        updateTexts();
        setQuestion();
        progress.dismiss();
        Toast toast = Toast.makeText(this, "Quiz is Ready", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
        View fore = findViewById(R.id.foreground);
        fore.setVisibility(View.INVISIBLE);
    }

    private void loadQuestions() throws IOException {
        if (!Question.isQuestionListReady()) {
            ((JavaPlay) this.getApplicationContext()).loadRawQuestions(genreSelection);
        }
        this.generator = new QuestionsGenerator();
    }
}
</code>```

答:
Problem is somewhere you are setting text as int. like in below line

highScoreText.setText(currentPlayer.getHighScore());

if getHighScore() return int then os will look for resource in string.xml which will give you .Resources$NotFoundException. Try to use it like below.

```<code>highScoreText.setText(String.valueOf(currentPlayer.getHighScore()));
</code>```

Or

```<code>highScoreText.setText(currentPlayer.getHighScore()+"");
</code>```

Body:
I am developing a quiz app when i run this app i am getting error android.content.res.Resources$NotFoundException: String resource ID #0x0 after changing the minimum sdk from 16 to 19.Please help me run this app

Here is my activity_main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.awwalsoft.javaplay.MainActivity">

    <LinearLayout
        android:id="@+id/data_list"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_weight="3"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view1"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:onClick="startGame"
                android:layout_height="match_parent">

                <LinearLayout

                    android:layout_width="match_parent"
                    android:orientation="vertical"
                    android:layout_height="match_parent">

                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/play"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/start"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view1_1"
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:background="@drawable/scoreboard"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:id="@+id/highscore"
                        android:gravity="center"
                        android:textSize="@dimen/textsizebutton"
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:layout_weight="2"/>

                    <TextView
                        android:text="@string/highscore"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

        </LinearLayout>

        <TextView
            android:text="@string/useapps"
            android:layout_marginTop="@dimen/eightdpmargin"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="@dimen/sptextsize2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_weight="3"
            android:layout_marginTop="@dimen/eightdpmargin"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="horizontal">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2"
                android:layout_width="@dimen/minhigh"
                android:onClick="javaBasicsLearningApp"
                android:layout_marginEnd="@dimen/cardviewmarginright"
                android:layout_height="match_parent">

                <LinearLayout

                    android:layout_width="match_parent"
                    android:orientation="vertical"
                    android:layout_height="match_parent">

                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jbl"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/jbl"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>
            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2_1"
                android:layout_width="@dimen/minhigh"
                android:onClick="javaDeepLearningApp"
                android:layout_marginEnd="@dimen/eightdpmargin"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jdl"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/jdl"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view2_2"
                android:layout_width="@dimen/minhigh"
                android:onClick="learnJdbcApp"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/jdbc"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"/>
                    <TextView
                        android:text="@string/ljdbc"
                        android:gravity="center"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/twozerotext"
                        android:textColor="@android:color/black"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

                </LinearLayout>

            </HorizontalScrollView>

        </LinearLayout>

        <LinearLayout
            android:layout_marginTop="@dimen/eightdpmargin"
            android:layout_weight="2"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/card_view3"
                android:onClick="helpClick"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_marginTop="@dimen/eightdpmargin"
                        android:src="@drawable/help"
                        android:layout_width="0dp"
                        android:layout_margin="@dimen/sixteendppadding"
                        android:layout_height="match_parent"
                        android:layout_weight="1"/>
                    <TextView
                        android:text="@string/help"
                        android:gravity="center"
                        android:id="@+id/helptext"
                        android:fontFamily="sans-serif-light"
                        android:textSize="@dimen/textsizemain"
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"/>

                </LinearLayout>

            </android.support.v7.widget.CardView>

        </LinearLayout>

    </LinearLayout>

  </LinearLayout>

here is my MainActivity.java file

package com.awwalsoft.javaplay;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    String moreApps1 = "com.awwalsoft.javabasicslearning";
    String moreApps2 = "com.awwalsoft.javadeeplearning";
    String moreApps3 = "com.awwalsoft.learnjdbc";
    private Player currentPlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        currentPlayer = ((JavaPlay) getApplication()).player; //gets player from lightquiz application
        updateHighScore();

    }

    public void javaBasicsLearningApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps1)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps1)));
        }

    }

    public void javaDeepLearningApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps2)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps2)));
        }

    }

    public void learnJdbcApp(View v){

        try {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("market://details?id=" + moreApps3)));
        } catch (android.content.ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + moreApps3)));
        }

    }

    public void helpClick(View view){
        Intent helpIntent = new Intent(this,Help.class);
        startActivity(helpIntent);
    }

    @Override
    public void onResume() {
        super.onResume();
        ((JavaPlay) this.getApplicationContext()).clearQuestions();
        updateHighScore();
    }
    @Override
    public void onBackPressed() {
        this.finish();
    }

    public void startGame(View view) {

                Intent intent = new Intent(this, PlayGame.class);
                startActivity(intent);

    }

    void selecGenre() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.dialog_title);
        String[] genres = QuestionGenre.names();
        builder.setItems(QuestionGenre.names(), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                beginQuizGame(QuestionGenre.names()[which]);
            }
        });

        AlertDialog dialog = builder.create();
        dialog.show();
    }

    void beginQuizGame(String genre) {
        Intent intent = new Intent(this, PlayGame.class);
        intent.putExtra("Genre", genre);
        startActivity(intent);

    }

    private void updateHighScore() {
        TextView highScoreText = (TextView) findViewById(R.id.highscore);
        highScoreText.setText(currentPlayer.getHighScore());
    }

}

here is my PlayGame.java file

package com.awwalsoft.javaplay;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;

public class PlayGame extends AppCompatActivity {
    private final int questionsDelay = 500;
    private final int questionsPoints = 10;
    private final int questionSeconds = 8;
    private int points;
    private int lives;
    private int correctAnswer;
    //Layout Stuff
    private ImageView correctImg;
    private ImageView wrongImg;
    private ImageView questionImg;
    private TextView questionText;
    private Button soundButton;
    private TextView pointsText;
    private TextView lifeText;
    private TextView countdownText;
    private Button[] answerButtons = new Button[4];

    private CountDownTimer countdown;
    private QuestionsGenerator generator;
    private ProgressDialog progress;

    private String genreSelection = null;
    private boolean gameFinished = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_game);

        Intent intent = getIntent();
        genreSelection = intent.getStringExtra("Genre");

        progress = new ProgressDialog(this);
        progress.setMessage("Loading Database ");
        progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progress.setIndeterminate(true);
        progress.show();

        new Thread(new Runnable() {
            public void run() {
                try {
                    loadQuestions();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                loadLayout();

                runOnUiThread(new Runnable() {
                    public void run() {
                        startGame();
                    }
                });
            }
        }).start();
    }

    @Override
    public void onPause() {
        super.onPause();
        countdown.cancel();
        hideQuestionMultimedia();
        this.finish();
        gameFinished = true;
        // gameOver();

    }

    @Override
    public void onBackPressed() {
        // this.finish();
        gameOver();
    }

    //an answer was clicked
    public void answerClicked(View view) {
        countdown.cancel();
        int answer; //-1 by default
        buttonsActive(false);
        switch (view.getId()) {
            case R.id.answer_1:
                answer = 1;
                break;
            case R.id.answer_2:
                answer = 2;
                break;
            case R.id.answer_3:
                answer = 3;
                break;
            case R.id.answer_4:
                answer = 4;
                break;
            default:
                throw new RuntimeException("Unknown button ID");
        }
        if (correctAnswer == answer) correctAnswer();
        else wrongAnswer();
        updateTexts();
        nextQuestion();
    }

    public void soundClick(View view) {
        switch (view.getId()) {
            case R.id.sound_button:
                playSound();
                break;
            default:
                throw new RuntimeException("Unknown button ID");

        }
    }

    //set a new question from generator

    private void playSound() {
        if (!gameFinished)
            ((JavaPlay) this.getApplicationContext()).soundHandler.playQuestionSound();
    }

    private void setQuestion() {
        if (!gameFinished) {
            hideQuestionMultimedia();
            buttonsActive(true);
            Question quest = generator.getQuestion();//get a randomized question

            if (!quest.isValid()) throw new RuntimeException("Invalid Question");
            this.correctAnswer = quest.getCorrectAnswer();
            for (int i = 0; i < 4; i++)
                answerButtons[i].setText(quest.getAnswer(i)); //set questions layout

            hideAnswerImage();
            questionText.setText(quest.getText());
            QuestionType qt = quest.type();
            switch (qt) {
                case TEXT:
                    //showQuestionText(((TextQuestion) quest).text);
                    break;
                case IMAGE:
                    showQuestionImage(((ImageQuestion) quest).image);
                    break;
                case SOUND:
                    showQuestionSound(((SoundQuestion) quest).sound);
                    playSound();
                    break;
                default:
                    throw new RuntimeException("Invalid question type");
            }
            countdown = new CountDownTimer(questionSeconds * 1000, 500) {
                @Override
                public void onTick(long millisUntilFinished) {
                    countdownText.setText(Integer.toString((int) (millisUntilFinished / 1000) + 1));
            /* if(millisUntilFinished/1000 == 1) {
                 wrongAnswer();
                 updateTexts();
                 nextQuestion();
             }*/
                }

                @Override
                public void onFinish() {
                    buttonsActive(false);
                    wrongAnswer();
                    updateTexts();
                    nextQuestion();
                }
            }.start();
        }
    }

    private void showQuestionSound(String sound) {
        soundButton.setVisibility(View.VISIBLE);
        soundButton.setClickable(true);
        ((JavaPlay) this.getApplicationContext()).soundHandler.setQuestionSound(sound);
    }

    private void showQuestionImage(String imagename) {
        int resourceId = this.getResources().getIdentifier(imagename, "drawable", this.getPackageName());
        questionImg.setImageResource(resourceId);
        questionImg.setVisibility(View.VISIBLE);
        //questionImg.setMaxHeight();
    }

    private void hideQuestionMultimedia() {
        questionImg.setVisibility(View.INVISIBLE);
        soundButton.setVisibility(View.INVISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.stopQuestionSound();
        soundButton.setClickable(false);
    }
    //next question after som time
    private void nextQuestion() {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (generator.size() == 0) gameOver(); //no more questions left
                else setQuestion();
            }
        }, questionsDelay);
    }

    //What happens when a correct answer was clicked
    private void correctAnswer() {
        points += questionsPoints;
        wrongImg.setVisibility(View.INVISIBLE);
        correctImg.setVisibility(View.VISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.playCorrectSound();
    }

    //What happens when a wrong answer was clicked
    private void wrongAnswer() {
        correctImg.setVisibility(View.INVISIBLE);
        wrongImg.setVisibility(View.VISIBLE);
        ((JavaPlay) this.getApplicationContext()).soundHandler.playWrongSound();
        lives--;
        if (lives == 0) gameOver();
    }

    //Hides any answer image (tick or cross)
    private void hideAnswerImage() {
        correctImg.setVisibility(View.INVISIBLE);
        wrongImg.setVisibility(View.INVISIBLE);
    }

    private void buttonsActive(boolean b) {
        for (Button button : answerButtons) {
            button.setClickable(b);
        }
    }

    private void loadLayout() {
        correctImg = (ImageView) findViewById(R.id.correct_img);
        wrongImg = (ImageView) findViewById(R.id.wrong_img);
        pointsText = (TextView) findViewById(R.id.points_text);
        lifeText = (TextView) findViewById(R.id.life_text);
        countdownText = (TextView) findViewById(R.id.countdown_text);
        questionImg = (ImageView) findViewById(R.id.question_image);
        questionText = (TextView) findViewById(R.id.question);
        soundButton = (Button) findViewById(R.id.sound_button);

        answerButtons[0] = (Button) findViewById(R.id.answer_1);
        answerButtons[1] = (Button) findViewById(R.id.answer_2);
        answerButtons[2] = (Button) findViewById(R.id.answer_3);
        answerButtons[3] = (Button) findViewById(R.id.answer_4);

        hideAnswerImage();
    }

    //Updates life and score texts
    private void updateTexts() {
        lifeText.setText("Life:" + lives);
        pointsText.setText("Score:" + points);
        countdownText.setText("");
    }

    private void gameOver() {
        //hideQuestionMultimedia();
        gameFinished = true;
        ((JavaPlay) this.getApplicationContext()).soundHandler.stopQuestionSound();
        soundButton.setClickable(false);
        countdown.cancel();
        buttonsActive(false);
        Intent intent = new Intent(this, GameOver.class);
        intent.putExtra("Score", points);
        startActivity(intent);
        this.finish();
    }

    //reloads questions from xml (old)
   /* private void reload_questions() throws IOException, XmlPullParserException {
        XmlResourceParser xmlq = getResources().getXml(R.xml.questions);
        MainActivity.generator.loadQuestions(xmlq);
        xmlq.close();
    }*/

    //Starts game
    private void startGame() {
        points = 0;
        lives = 3;
        gameFinished = false;
        buttonsActive(true);
        updateTexts();
        setQuestion();
        progress.dismiss();
        Toast toast = Toast.makeText(this, "Quiz is Ready", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
        View fore = findViewById(R.id.foreground);
        fore.setVisibility(View.INVISIBLE);
    }

    private void loadQuestions() throws IOException {
        if (!Question.isQuestionListReady()) {
            ((JavaPlay) this.getApplicationContext()).loadRawQuestions(genreSelection);
        }
        this.generator = new QuestionsGenerator();
    }
}

Body:
Problem is somewhere you are setting text as int. like in below line

highScoreText.setText(currentPlayer.getHighScore());

if getHighScore() return int then os will look for resource in string.xml which will give you .Resources$NotFoundException. Try to use it like below.

highScoreText.setText(String.valueOf(currentPlayer.getHighScore()));

Or

highScoreText.setText(currentPlayer.getHighScore()+"");


问:
Assign the number of rows with text to a variable
First let me start by saying i am fairly new to programming, especially to Excel VBA. I am writing a long code to help me optimize some of my daily tasks. For now there is one thing i cannot figure out yet, so i will paste only this part of the code.

I want to count the number of active rows(such which have text in them) in the target sheet i am using and assign that number to a variable (integer).

Can you please explain to me how to do that?

Here is the code i thought it would work:

```<code>targetSheet.Range("A2").Select
targetSheet.Range(Selection, Selection.End(xlDown)).Select
Selection.Count

Dim count As Integer

count = Selection.Count
</code>```

obviously it doesn't work and i cannot refer to 'count' in the continuation of the code (it gives me an error)

i would be very thankful if you could help me with that!

Regards,
Mihail

答:
Try the code below:

```<code>Dim CellsCount As Long

With targetSheet
    .Range("A2:A" & .Range("A2").End(xlDown).Row).Select ' <-- if you must use Select

    CellsCount = Selection.Count
End With
</code>```

However, you don't need to Select the range to count the number of cells:

```<code>With targetSheet
    CellsCount = .Range("A2", .Range("A2").End(xlDown)).Cells.Count
End With
</code>```

Body:
First let me start by saying i am fairly new to programming, especially to Excel VBA. I am writing a long code to help me optimize some of my daily tasks. For now there is one thing i cannot figure out yet, so i will paste only this part of the code.

I want to count the number of active rows(such which have text in them) in the target sheet i am using and assign that number to a variable (integer).

Can you please explain to me how to do that?

Here is the code i thought it would work:

targetSheet.Range("A2").Select
targetSheet.Range(Selection, Selection.End(xlDown)).Select
Selection.Count

Dim count As Integer

count = Selection.Count

obviously it doesn't work and i cannot refer to 'count' in the continuation of the code (it gives me an error)

i would be very thankful if you could help me with that!

Regards,
Mihail

Body:
Try the code below:

Dim CellsCount As Long

With targetSheet
    .Range("A2:A" & .Range("A2").End(xlDown).Row).Select ' <-- if you must use Select

    CellsCount = Selection.Count
End With

However, you don't need to Select the range to count the number of cells:

With targetSheet
    CellsCount = .Range("A2", .Range("A2").End(xlDown)).Cells.Count
End With


问:
PHP Security - Sanitize & Clean
I have a built a script around class.upload from http://www.verot.net/php_class_upload.htm

Basically what it is that all my images are stored on the server in a directory called /images/

The script I built basically takes some parameters from my website such as /xyzDir/tomnjerry.jpg?w=100&h=100&fill=1&color=fff

Then I have mod_rewrite which reads the file from /xyzDir/ into a php script which then translates the width and height and returns the image.

Lately I have noticed some idiots from Turkey trying to input weird characters into the parameters w= and h=

On my script I do check to make sure only integer is allowed in width and heigh and fill can be either 1 or 2 and color can only be certain values which i check via array.

I just want to see if there is anything else I should be doing in order to avoid getting hacked.

Thanks

答: Make sure the image name does not contain string like "../". Depending on your script, that could be a way to step out images directory and make the script deliver other files.</p>

Title: PHP Security - Sanitize & Clean