问:
add rows automatically row html data grid with drop down menu
I would like to ask if you can help me fix my code. I built an HTML grid and have a button that should automatically add a new row. The function associated with the button doesn't work.

Here's the HTML code

```<code><html>
<head>
    <script src="test.js"></script>
</head>
<body>
    <div id="wrapper">
        <table align='center' cellspacing=2 cellpadding=5 id="data_table" border=1>
            <tr>
                <th>Advertiser</th>
                <th>Formato</th>
                <th>Tipo</th>
                <th>Autoplay</th>
                <th>Audio</th>
            </tr>
            <tr id="row1">
                <td id="advertiser_row1">
                    <select name="client">
                        <option value="Mcvities">Mcvities</option>
                        <option value="Enel">Enel</option>
                        <option value="Brita">Brita</option>
                    </select>
                </td>
                <td id="formato_row1">
                    <select name="formato">
                        <option value="intro shaa">intro shaa</option>
                        <option value="intro xaxis">intro xaxis</option>
                        <option value="carousel">carousel</option>
                        <option value="mid-strip">mid-strip</option>
                    </select>
                </td>
                <td id="tipo_row1">
                    <select name="tipi">
                        <option value="video">video</option>
                        <option value="immagine">immagine</option>
                    </select>
                </td>
                <td id="audio_row1">
                    <select name="audio">
                        <option value="video">yes</option>
                        <option value="immagine">no</option>
                    </select>
                </td>
                <td id="tipo_row1">
                    <select name="autoplay">
                        <option value="video">yes</option>
                        <option value="immagine">no</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><input type="text" id="new_cl"></td>
                <td><input type="text" id="new_fo"></td>
                <td><input type="text" id="new_ti"></td>
                <td><input type="text" id="new_au"></td>
                <td><input type="text" id="new_at"></td>
                <td><input type="button" class="add" onclick="add_row();" value="Add Row"></td>
            </tr>
        </table>
    </div>
</body>
</html>
</code>```

here my js:

```<code>function add_row()
{
 var new_ad=document.getElementById("new_cl").value;
 var new_im=document.getElementById("new_fo").value;
 var new_cp=document.getElementById("new_ti").value;
 var new_st=document.getElementById("new_au").value;
 var new_en=document.getElementById("new_at").value;

 var table=document.getElementById("data_table");
 var table_len=(table.rows.length)-1;
 var row = table.insertRow(table_len).outerHTML="<tr id='row"+table_len+"'><td id='advertiser_row"+table_len+"'>"+new_cl+"</td><td id='formato_row"+table_len+"'>"+new_fo+"</td><td id='tipo_row"+table_len+"'>"+ti_cp+"</td><td id='audio_row"+table_len+"'>"+au_cl+"</td><td id='autoplay_row"+table_len+"'>"+new_at+"</td>;

 document.getElementById("new_cl").value="";
 document.getElementById("new_fo").value="";
 document.getElementById("new_ti").value="";
 document.getElementById("new_au").value="";
 document.getElementById("new_at").value="";
}
</code>```

答:
Try this:

Change:

```<code>function add_row()
{
    var table = document.getElementById("myTable");
    var row = table.insertRow(0);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    var cell3 = row.insertCell(2);
    var cell4 = row.insertCell(3);
    cell1.innerHTML = "NEW CELL1";
    cell2.innerHTML = "NEW CELL2";
    cell3.innerHTML = "NEW CELL3";
    cell4.innerHTML = "NEW CELL4";
}
</code>```

Body:
I would like to ask if you can help me fix my code. I built an HTML grid and have a button that should automatically add a new row. The function associated with the button doesn't work.

Here's the HTML code

                Advertiser
                Formato
                Tipo
                Autoplay
                Audio

                    <select name="client">
                        <option value="Mcvities">Mcvities</option>
                        <option value="Enel">Enel</option>
                        <option value="Brita">Brita</option>
                    </select>

                    <select name="formato">
                        <option value="intro shaa">intro shaa</option>
                        <option value="intro xaxis">intro xaxis</option>
                        <option value="carousel">carousel</option>
                        <option value="mid-strip">mid-strip</option>
                    </select>

                    <select name="tipi">
                        <option value="video">video</option>
                        <option value="immagine">immagine</option>
                    </select>

                    <select name="audio">
                        <option value="video">yes</option>
                        <option value="immagine">no</option>
                    </select>

                    <select name="autoplay">
                        <option value="video">yes</option>
                        <option value="immagine">no</option>
                    </select>

                <input type="text" id="new_cl">
                <input type="text" id="new_fo">
                <input type="text" id="new_ti">
                <input type="text" id="new_au">
                <input type="text" id="new_at">
                <input type="button" class="add" onclick="add_row();" value="Add Row">

here my js:

function add_row()
{
 var new_ad=document.getElementById("new_cl").value;
 var new_im=document.getElementById("new_fo").value;
 var new_cp=document.getElementById("new_ti").value;
 var new_st=document.getElementById("new_au").value;
 var new_en=document.getElementById("new_at").value;

 var table=document.getElementById("data_table");
 var table_len=(table.rows.length)-1;
 var row = table.insertRow(table_len).outerHTML="
"+new_cl+"	"+new_fo+"	"+ti_cp+"	"+au_cl+"	"+new_at+"	;

 document.getElementById("new_cl").value="";
 document.getElementById("new_fo").value="";
 document.getElementById("new_ti").value="";
 document.getElementById("new_au").value="";
 document.getElementById("new_at").value="";
}

Body:
Try this:

Change: <table id="myTable">

function add_row()
{
    var table = document.getElementById("myTable");
    var row = table.insertRow(0);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    var cell3 = row.insertCell(2);
    var cell4 = row.insertCell(3);
    cell1.innerHTML = "NEW CELL1";
    cell2.innerHTML = "NEW CELL2";
    cell3.innerHTML = "NEW CELL3";
    cell4.innerHTML = "NEW CELL4";
}


来源: stackexchange

问:
Cannot find package folder under src
Iam using android studio 2.3.2..
I cannot find package under srcenter image description here</p>

答: You are currently looking at the project view. In the top spinner where it says project (above calculator) you can switch it to android where it will show the package folder "com.something.calculator" which is what you are like used to seeing. However it is important to note that in the project view that you are currently in, if you click main, then java You,  should see your package folder.</p>

ContentLicense: CC BY-SA 3.0

Title: Cannot find package folder under src


问:
Adding a mock Datatable in Unit Testing
I am Unit Testing one of my functions. Here is my code:

```<code>public void TestLabels()
{

  //Step 1: Creating a mock table with columns exactly like in the real table.
  DataTable table = new DataTable();

  DataRow mydatarow;
  mydatarow = table.NewRow();

  //Step 2: Adding the row as same as the Real Data!

  mydatarow["Name"] = "Test";
  mydatarow["Address"] = "00000 ST.";
  mydatarow["ZipCode"] = "77665";
  mydatarow["Tracking#"] = "";

  table.Rows.Add(mydatarow);

  foreach (DataColumn column in table.Columns)
    Console.WriteLine(column.ColumnName);

  //Step 3: Call method we are testing.
  var updateTable = IceTechUPSClient.Instance.CreateLabels(table);

  foreach (DataRow row in updateTable.Rows)
  {
    var trackingNumber = row["Tracking#"].ToString();
    Assert.IsFalse(String.IsNullOrWhiteSpace(trackingNumber), "Expecting tracking number generated for every row!");
    Assert.IsTrue(File.Exists(trackingNumber + ".gif"));
  }

}
</code>```

Now I am getting an error:  Column 'Name' does not belong to table. As you can see I have specified column name "Name" here and also added that particular row. Then why I am getting this error? Any help?

Thanks!

答:
You haven't set up your columns (unless you've missed out some code in your example).

You need to create the columns with the required names before you can access them like this:

```<code>var columnSpec = new DataColumn
                    {
                        DataType = typeof(string),
                        ColumnName = "Name"
                    };
this.table.Columns.Add(columnSpec);
</code>```

When you read data from the database if you've set AutoGenerateColumns to true (the default) you don't need to do this explicitly as it's done for you behind the scenes.

ContentLicense: CC BY-SA 2.5

Title: Adding a mock Datatable in Unit Testing

Body:
I am Unit Testing one of my functions. Here is my code:

public void TestLabels()
{

  //Step 1: Creating a mock table with columns exactly like in the real table.
  DataTable table = new DataTable();

  DataRow mydatarow;
  mydatarow = table.NewRow();

  //Step 2: Adding the row as same as the Real Data!

  mydatarow["Name"] = "Test";
  mydatarow["Address"] = "00000 ST.";
  mydatarow["ZipCode"] = "77665";
  mydatarow["Tracking#"] = "";

  table.Rows.Add(mydatarow);

  foreach (DataColumn column in table.Columns)
    Console.WriteLine(column.ColumnName);

  //Step 3: Call method we are testing.
  var updateTable = IceTechUPSClient.Instance.CreateLabels(table);

  foreach (DataRow row in updateTable.Rows)
  {
    var trackingNumber = row["Tracking#"].ToString();
    Assert.IsFalse(String.IsNullOrWhiteSpace(trackingNumber), "Expecting tracking number generated for every row!");
    Assert.IsTrue(File.Exists(trackingNumber + ".gif"));
  }

}

Now I am getting an error:  Column 'Name' does not belong to table. As you can see I have specified column name "Name" here and also added that particular row. Then why I am getting this error? Any help?

Thanks!

Body:
You haven't set up your columns (unless you've missed out some code in your example).

You need to create the columns with the required names before you can access them like this:

var columnSpec = new DataColumn
                    {
                        DataType = typeof(string),
                        ColumnName = "Name"
                    };
this.table.Columns.Add(columnSpec);

When you read data from the database if you've set AutoGenerateColumns to true (the default) you don't need to do this explicitly as it's done for you behind the scenes.


问:
In Excel how can I share a spreadsheet attachment in Gmail? by default it opens up Outlook
Whilst open in Excel how can I send the file as an attachment in Gmail?

In Excel, File > Share > Email by default opens up Outlook

how can I change this to open up and attach by default in Gmail

答: You would have to use Outlook as your GMail client. There is no way to change Excel to share to a web email account.</p>


问:
Determining if get handler in Proxy object is handling a function call
I currently have a Proxy object that I want to capture property calls to if the property is not defined.
A basic version of my code would be something like this.

```<code>var a = new Proxy({}, {
    get: function(target, name, receiver) {
        if (target in name) {
            return target[name];
        } else {
            function a() {
                return arguments;
            }
            var args = a();
            return [target, name, receiver, args];
        }
    }
});
</code>```

Property calls to a here (i.e: a.b; a.c() etc) should return the target, name, receiver and arguments of the property call.

The problem I wish to solve, however, requires me to know whether the property call is for a property or a function, such that I can apply different treatments to each. Checking the length of the arguments object does not work, as calling a.c() would yield a length of 0 just like a.b, so it would be treated as a plain property and not a method.

Is there a way, therefore, to identify whether the property attempting to be accessed is being called as a function or not.

UPDATE: I should clarify, this method needs to work if the accessed property/method is undefined, as well as existing.

答:
Would the typeof operator work for you?

For example:

```<code>if(typeof(a) === "function")
{
    ...
}
else
{
    ...
}
</code>```

Body:
I currently have a Proxy object that I want to capture property calls to if the property is not defined.
A basic version of my code would be something like this.

var a = new Proxy({}, {
    get: function(target, name, receiver) {
        if (target in name) {
            return target[name];
        } else {
            function a() {
                return arguments;
            }
            var args = a();
            return [target, name, receiver, args];
        }
    }
});

Property calls to a here (i.e: a.b; a.c() etc) should return the target, name, receiver and arguments of the property call.

The problem I wish to solve, however, requires me to know whether the property call is for a property or a function, such that I can apply different treatments to each. Checking the length of the arguments object does not work, as calling a.c() would yield a length of 0 just like a.b, so it would be treated as a plain property and not a method.

Is there a way, therefore, to identify whether the property attempting to be accessed is being called as a function or not.

UPDATE: I should clarify, this method needs to work if the accessed property/method is undefined, as well as existing.

Body:
Would the typeof operator work for you?

For example:

if(typeof(a) === "function")
{
    ...
}
else
{
    ...
}


问:
How do I get a SELECT date query to run on my SQL database from C# application?
```<code>string dateType = DateFieldDropDown.SelectedItem.ToString();
string DateField1 = DateTextBox.Text;
string DateField2 = dateSelection2Text.Text;
DateField1 = Convert.ToDateTime(DateField1).ToString("yyyy-MM-dd");
DateField2 = Convert.ToDateTime(DateField2).ToString("yyyy-MM-dd");
string DateFiled = "DateFiled";

if (dateType == "DateFiled")
{
  SqlDataSource1.SelectParameters.Add(new Parameter("DateFiled",  TypeCode.String, DateFiled));
  SqlDataSource1.SelectParameters.Add(new Parameter("DateField1", TypeCode.String, DateField1));
  SqlDataSource1.SelectParameters.Add(new Parameter("DateField2", TypeCode.String, DateField2));

  SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE @DateFiled BETWEEN @DateField1 AND @DateField2";
   SqlDataSource1.DataBind();
   GridView1.DataBind();
</code>```

I'm not sure anyone can help without seeing the database behind, but I thought I'd give it a shot.  So I'm querying my database, trying to get records within a certain date range out. No errors thrown, just no results, despite there being associated data behind which should be pulled in.  I've tested the SQL query on the database in a SQL editor using the dates rather than the parameter variables and gotten the correct results. I think it may need a CAST in order to be able to check the date in the string to the datetime in the database?  But when I try putting that in
SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE @DateFiled BETWEEN CAST(@DateField1 AS DATE) AND CAST(@DateField2 AS DATE)";
I get an error saying Conversion failed when converting date and/or time from character string.  Any ideas appreciated.

答:
```<code> string dateType = DateFieldDropDown.SelectedItem.ToString();
 string DateField1 = DateTextBox.Text;
 string DateField2 = dateSelection2Text.Text;
 if (dateType == "DateFiled")
 {
 SqlDataSource1.SelectParameters.Add(new Parameter("DateField1", TypeCode.String, DateField1));
   SqlDataSource1.SelectParameters.Add(new Parameter("DateField2", TypeCode.String, DateField2));

   SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE DateFiled BETWEEN CAST(@DateField1 AS DATE) AND CAST(@DateField2 AS DATE)";
        SqlDataSource1.DataBind();
        GridView1.DataBind();
</code>```

I needed the CAST in place to get the date lookup in the SQL database to work correctly but as Gareth said, it showed a conversion error.  By not changing the format to yyyy-MM-dd, and using the CAST, it worked correctly.  I also needed to remove DateFiled as a parameter as it should have just been in the SQL statement as a column name after the WHERE clause.

Body:
string dateType = DateFieldDropDown.SelectedItem.ToString();
string DateField1 = DateTextBox.Text;
string DateField2 = dateSelection2Text.Text;
DateField1 = Convert.ToDateTime(DateField1).ToString("yyyy-MM-dd");
DateField2 = Convert.ToDateTime(DateField2).ToString("yyyy-MM-dd");
string DateFiled = "DateFiled";

if (dateType == "DateFiled")
{
  SqlDataSource1.SelectParameters.Add(new Parameter("DateFiled",  TypeCode.String, DateFiled));
  SqlDataSource1.SelectParameters.Add(new Parameter("DateField1", TypeCode.String, DateField1));
  SqlDataSource1.SelectParameters.Add(new Parameter("DateField2", TypeCode.String, DateField2));

  SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE @DateFiled BETWEEN @DateField1 AND @DateField2";
   SqlDataSource1.DataBind();
   GridView1.DataBind();

I'm not sure anyone can help without seeing the database behind, but I thought I'd give it a shot.  So I'm querying my database, trying to get records within a certain date range out. No errors thrown, just no results, despite there being associated data behind which should be pulled in.  I've tested the SQL query on the database in a SQL editor using the dates rather than the parameter variables and gotten the correct results. I think it may need a CAST in order to be able to check the date in the string to the datetime in the database?  But when I try putting that in
SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE @DateFiled BETWEEN CAST(@DateField1 AS DATE) AND CAST(@DateField2 AS DATE)";
I get an error saying Conversion failed when converting date and/or time from character string.  Any ideas appreciated.

Body:
 string dateType = DateFieldDropDown.SelectedItem.ToString();
 string DateField1 = DateTextBox.Text;
 string DateField2 = dateSelection2Text.Text;
 if (dateType == "DateFiled")
 {
 SqlDataSource1.SelectParameters.Add(new Parameter("DateField1", TypeCode.String, DateField1));
   SqlDataSource1.SelectParameters.Add(new Parameter("DateField2", TypeCode.String, DateField2));

   SqlDataSource1.SelectCommand = "SELECT * FROM tbl_dateCorrection WHERE DateFiled BETWEEN CAST(@DateField1 AS DATE) AND CAST(@DateField2 AS DATE)";
        SqlDataSource1.DataBind();
        GridView1.DataBind();

I needed the CAST in place to get the date lookup in the SQL database to work correctly but as Gareth said, it showed a conversion error.  By not changing the format to yyyy-MM-dd, and using the CAST, it worked correctly.  I also needed to remove DateFiled as a parameter as it should have just been in the SQL statement as a column name after the WHERE clause.


问:
NodeJs get JSON for each url request
Hello i created an JSON downloader with nodeJS if use one url this works fine , the problem begins if i try create several JSON files from an url array, the JSON name should be equal to used url any suggestions?
Thanks

im using 2 npm modules

```<code>var request = require("request");

var fs = require('fs');

var url =[
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/"
]
request({
    url: url,
    json: true
}, function (error, response, body) {
    if (!error && response.statusCode === 200) {
        fs.writeFile("de.json", JSON.stringify(response), function(err){
            if(err){console.log(err);} else {console.log("create"  + url + 'JSON ');}
        });
    }
})
</code>```

答:
request does not support arrays, you need to use loops

From doc: uri || url - fully qualified uri or a parsed url object from url.parse()

```<code>var request = require("request");

var fs = require('fs');

var urls =[
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/"
];

urls.forEach(function (url) {
    request({
        url: url,
        json: true
    }, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            fs.writeFile("de.json", JSON.stringify(response), function(err){
                if(err){console.log(err);} else {console.log("create"  + url + 'JSON ');}
            });
        }
    })
});
</code>```

Title: NodeJs get JSON for each url request

Body:
Hello i created an JSON downloader with nodeJS if use one url this works fine , the problem begins if i try create several JSON files from an url array, the JSON name should be equal to used url any suggestions?
Thanks

im using 2 npm modules

var request = require("request");

var fs = require('fs');

var url =[
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/"
]
request({
    url: url,
    json: true
}, function (error, response, body) {
    if (!error && response.statusCode === 200) {
        fs.writeFile("de.json", JSON.stringify(response), function(err){
            if(err){console.log(err);} else {console.log("create"  + url + 'JSON ');}
        });
    }
})

Body:
request does not support arrays, you need to use loops

From doc: uri || url - fully qualified uri or a parsed url object from url.parse()

var request = require("request");

var fs = require('fs');

var urls =[
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/",
    "http://ip.jsontest.com/"
];

urls.forEach(function (url) {
    request({
        url: url,
        json: true
    }, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            fs.writeFile("de.json", JSON.stringify(response), function(err){
                if(err){console.log(err);} else {console.log("create"  + url + 'JSON ');}
            });
        }
    })
});

ContentLicense: CC BY-SA 4.0


问:
cython - determining the number of items in pointer variable
How would I determine the number of elements in a pointer variable in cython? I saw that in C one way seems to be sizeof(ptr)/sizeof(int), if the pointer points to int variables. But that doesn't seem to work in cython. E.g. when I tried to join two memory views into a single pointer like so:

```<code>from libc.stdlib cimport malloc, free
cdef int * join(int[:] a, int[:] b):

    cdef:
        int n_a = a.shape[0]
        int n_b = b.shape[0]
        int new_size =  n_a + n_b
        int *joined = <int *> malloc(new_size*sizeof(int))
        int i
    try:
        for i in range(n_a):
            joined[i] = a[i]

        for i in range(n_b):
            joined[n_a+i] = b[i]

        return joined
    finally:
        free(joined)

@cython.cdivision(True)
def join_memviews(int[:] n, int[:] m):

    cdef int[:] arr_fst = n
    cdef int[:] arr_snd = m
    cdef int *arr_new
    cdef int new_size

    arr_new = join(arr_fst,arr_snd)
    new_size = sizeof(arr_new)/sizeof(int)

    return [arr_new[i] for i in range(new_size)]
</code>```

I do not get the desired result when calling join_memviews from a python script, e.g.:

```<code># in python
a = np.array([1,2])
b = np.array([3,4])
a_b = join_memviews(a,b)
</code>```

I also tried using the types

```<code>DTYPE = np.int
ctypedef np.int_t DTYPE_t
</code>```

as the arguement inside sizeof(), but that didn't work either.

Edit: The handling of the pointer variable was apparently a bit careless of me. I hope the following is fine (even though it might not be a prudent approach):

```<code>cdef int * join(int[:] a, int[:] b, int new_size):

    cdef:
        int *joined = <int *> malloc(new_size*sizeof(int))
        int i

    for i in range(n_a):
        joined[i] = a[i]

    for i in range(n_b):
        joined[n_a+i] = b[i]

    return joined

def join_memviews(int[:] n, int[:] m):

    cdef int[:] arr_fst = n
    cdef int[:] arr_snd = m
    cdef int *arr_new
    cdef int new_size = n.shape[0] + m.shape[0]

    try:
        arr_new = join(arr_fst,arr_snd, new_size)

        return [arr_new[i] for i in range(new_size)]
    finally:
        free(arr_new)
</code>```

答:
You can't. It doesn't work in C either. sizeof(ptr) returns the amount of memory used to store the pointer (i.e. typically 4 or 8 depending on your system) rather than the length of the array. The lengths of your malloced arrays are something that you need to keep track of manually.

Additionally the following code is a recipe for disaster:

```<code>cdef int *joined = <int *> malloc(new_size*sizeof(int))
try:
   return joined
finally:
   free(joined)
</code>```

The free happens immediately on function exit so that an invalid pointer is returned to the calling function.

You should be using properly managed Python arrays (either from numpy or the standard library array module) unless you absolutely can't avoid it.

Body:
How would I determine the number of elements in a pointer variable in cython? I saw that in C one way seems to be sizeof(ptr)/sizeof(int), if the pointer points to int variables. But that doesn't seem to work in cython. E.g. when I tried to join two memory views into a single pointer like so:

from libc.stdlib cimport malloc, free
cdef int * join(int[:] a, int[:] b):

    cdef:
        int n_a = a.shape[0]
        int n_b = b.shape[0]
        int new_size =  n_a + n_b
        int *joined = <int *> malloc(new_size*sizeof(int))
        int i
    try:
        for i in range(n_a):
            joined[i] = a[i]

        for i in range(n_b):
            joined[n_a+i] = b[i]

        return joined
    finally:
        free(joined)

@cython.cdivision(True)
def join_memviews(int[:] n, int[:] m):

    cdef int[:] arr_fst = n
    cdef int[:] arr_snd = m
    cdef int *arr_new
    cdef int new_size

    arr_new = join(arr_fst,arr_snd)
    new_size = sizeof(arr_new)/sizeof(int)

    return [arr_new[i] for i in range(new_size)]

I do not get the desired result when calling join_memviews from a python script, e.g.:

# in python
a = np.array([1,2])
b = np.array([3,4])
a_b = join_memviews(a,b)

I also tried using the types

DTYPE = np.int
ctypedef np.int_t DTYPE_t

as the arguement inside sizeof(), but that didn't work either.

Edit: The handling of the pointer variable was apparently a bit careless of me. I hope the following is fine (even though it might not be a prudent approach):

cdef int * join(int[:] a, int[:] b, int new_size):

    cdef:
        int *joined = <int *> malloc(new_size*sizeof(int))
        int i

    for i in range(n_a):
        joined[i] = a[i]

    for i in range(n_b):
        joined[n_a+i] = b[i]

    return joined

def join_memviews(int[:] n, int[:] m):

    cdef int[:] arr_fst = n
    cdef int[:] arr_snd = m
    cdef int *arr_new
    cdef int new_size = n.shape[0] + m.shape[0]

    try:
        arr_new = join(arr_fst,arr_snd, new_size)

        return [arr_new[i] for i in range(new_size)]
    finally:
        free(arr_new)

Body:
You can't. It doesn't work in C either. sizeof(ptr) returns the amount of memory used to store the pointer (i.e. typically 4 or 8 depending on your system) rather than the length of the array. The lengths of your malloced arrays are something that you need to keep track of manually.

Additionally the following code is a recipe for disaster:

cdef int *joined = <int *> malloc(new_size*sizeof(int))
try:
   return joined
finally:
   free(joined)

The free happens immediately on function exit so that an invalid pointer is returned to the calling function.

You should be using properly managed Python arrays (either from numpy or the standard library array module) unless you absolutely can't avoid it.


问:
Sorting date m/y format in a data frame in R
I am trying to sort date column which is in the format M/Y. I tried using several ways given in other posts but none helped. Please suggest.
For 2012 it shows correctly with all the months given with 2012 but then it changes the pattern. Thank you.

Here is how it looks like currently

答:
Using lubridate and dplyr:

```<code>library(dplyr)
library(lubridate)
df <- data.frame( monyear = c( "1/12", "10/13", "1/13", "2/10" ),
                  amount = 1:4,
                  prices = 1:4 )
</code>```

Original Data:

```<code>  monyear amount prices
1    1/12      1      1
2   10/13      2      2
3    1/13      3      3
4    2/10      4      4
</code>```

To sort by date:

```<code>df <- df %>%
      arrange( parse_date_time(monyear,"my") )
</code>```

The function parse_date_time will read the format as "my" or "month year"

Output:

```<code>  monyear amount prices
1    2/10      4      4
2    1/12      1      1
3    1/13      3      3
4   10/13      2      2
</code>```

Body:
Using lubridate and dplyr:

library(dplyr)
library(lubridate)
df <- data.frame( monyear = c( "1/12", "10/13", "1/13", "2/10" ),
                  amount = 1:4,
                  prices = 1:4 )

Original Data:

  monyear amount prices
1    1/12      1      1
2   10/13      2      2
3    1/13      3      3
4    2/10      4      4

To sort by date:

df <- df %>%
      arrange( parse_date_time(monyear,"my") )

The function parse_date_time will read the format as "my" or "month year"

Output:

  monyear amount prices
1    2/10      4      4
2    1/12      1      1
3    1/13      3      3
4   10/13      2      2


问:
Expose Android and iOS native code SDK to Javascript in Ionic
I actually found a third party plugin that I want to use on one of my project. The goal is to create an Ionic application for that to avoid wasting time coding in native for both Android and iOS.

The problem is that the plugin I found has only SDK for Android and iOS. After a discussion on their forum, a technical guy told me it was possible for me to use that on Ionic by creating a plugin to expose the code to the Javascript.

Do you know where I could start ?
Do you have any tips or advice on how I could do that ?

Thanks !

答:
I actually found a third party plugin that I want to use on one of my project.

By plugin I understand you mean a Cordova plugin. A link would be nice.

a technical guy told me it was possible for me to use that on Ionic by creating a plugin to expose the code to the Javascript.

By creating a plugin to expose the code (of the Cordova plugin?) to javascript, I understand you want to make an Ionic wrapper for that Cordova plugin.

If so, first check that your plugin doesn't already have a Cordova wrapper in the list of those over at Ionic Native.

If not, then you can have a look at how all the other wrappers are already written and get started from there.

If you actually want to create your own cordova plugin, then here's a great tutorial by Ionic's CEO to help you out.


问:
Eclipse startup failure Google plugins
I recently installed some Google plugins on Eclipse indigo and after restart it fails to load. The log file in  workspace shows a bunch of errors surrounding !MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'.   It also appears that I maybe missing something due to a partial install.  Anybody know whats up?</p>

```<code>!SESSION 2014-08-11 14:23:59.293 -----------------------------------------------
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.ecf.provider.filetransfer 4 0 2014-08-11 14:25:46.910
!MESSAGE org.eclipse.core.runtime.Status[plugin=org.eclipse.ecf.provider.filetransfer;code=4;message=hardClose;severity4;exception=java.io.IOException: Stream closed;children=[]]
!STACK 0
java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at org.apache.commons.httpclient.ContentLengthInputStream.read(ContentLengthInputStream.java:170)
    at org.apache.commons.httpclient.ContentLengthInputStream.read(ContentLengthInputStream.java:184)
    at org.apache.commons.httpclient.ChunkedInputStream.exhaustInputStream(ChunkedInputStream.java:369)
    at org.apache.commons.httpclient.ContentLengthInputStream.close(ContentLengthInputStream.java:118)
    at java.io.FilterInputStream.close(Unknown Source)
    at org.apache.commons.httpclient.AutoCloseInputStream.notifyWatcher(AutoCloseInputStream.java:194)
    at org.apache.commons.httpclient.AutoCloseInputStream.close(AutoCloseInputStream.java:158)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.hardClose(AbstractRetrieveFileTransfer.java:331)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.hardClose(HttpClientRetrieveFileTransfer.java:396)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.cancel(HttpClientRetrieveFileTransfer.java:382)
    at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.handleTransferEvent(FileReader.java:173)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.fireTransferReceiveDataEvent(AbstractRetrieveFileTransfer.java:388)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.fireTransferReceiveDataEvent(HttpClientRetrieveFileTransfer.java:1163)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.handleReceivedData(AbstractRetrieveFileTransfer.java:288)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer$1.performFileTransfer(AbstractRetrieveFileTransfer.java:173)
    at org.eclipse.ecf.filetransfer.FileTransferJob.run(FileTransferJob.java:73)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SESSION 2014-08-11 23:26:30.697 -----------------------------------------------
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:45:42.431
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:45:42.431
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.431
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.431
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:45:42.441
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:45:42.441
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.441
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.441
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:58:19.158
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:58:19.158
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.158
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.158
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:58:19.159
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:58:19.159
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.159
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.159
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found
!SESSION 2014-08-12 21:17:29.320 --------------------------------------------    ---
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Co    rporation
BootLoader constants:     OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:      -product org.eclipse.epp.package.jee.p    roduct
Command-line argument    s:  -os win32 -ws win32 -arch x86 -prod    uct org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.ui 4 4 2014-08-12 21:17:42.332
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'

!ENTRY org.eclipse.ui 4 0 2014-08-12 21:17:42.334
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.ExceptionInInitializerError
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    ... 51 more
Caused by: java.lang.IllegalStateException: No suitable oauthClientProvider extension point found
    at com.google.gdt.eclipse.login.GoogleLogin.getClientIdAndSecretFromExtensionPoints(GoogleLogin.java:104)
    at com.google.gdt.eclipse.login.GoogleLogin.<clinit>(GoogleLogin.java:77)
    ... 58 more
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2014-08-12 21:17:42.337
!MESSAGE Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
!STACK 0
java.lang.ExceptionInInitializerError
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.IllegalStateException: No suitable oauthClientProvider extension point found
    at com.google.gdt.eclipse.login.GoogleLogin.getClientIdAndSecretFromExtensionPoints(GoogleLogin.java:104)
    at com.google.gdt.eclipse.login.GoogleLogin.<clinit>(GoogleLogin.java:77)
    ... 58 more

!ENTRY org.eclipse.ui.workbench 4 2 2014-08-12 21:17:42.338
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
    at org.eclipse.jface.action.ControlContribution.computeWidth(ControlContribution.java:54)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:100)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

!ENTRY org.eclipse.ui 4 4 2014-08-12 21:17:42.521
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'

!ENTRY org.eclipse.ui 4 0 2014-08-12 21:17:42.521
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$22.runWithException(Workbench.java:1216)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.gdt.eclipse.login.GoogleLogin
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
</code>```

答:
Enter in the YOUR_WORKSPACE/.metadata search for "google" and delete all folders
In the first line of your "eclipse.ini" include:
-clean
Start you eclipse

This work for me.

Title: Eclipse startup failure Google plugins

Body:
I recently installed some Google plugins on Eclipse indigo and after restart it fails to load. The log file in  workspace shows a bunch of errors surrounding !MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'.   It also appears that I maybe missing something due to a partial install.  Anybody know whats up?

!SESSION 2014-08-11 14:23:59.293 -----------------------------------------------
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.ecf.provider.filetransfer 4 0 2014-08-11 14:25:46.910
!MESSAGE org.eclipse.core.runtime.Status[plugin=org.eclipse.ecf.provider.filetransfer;code=4;message=hardClose;severity4;exception=java.io.IOException: Stream closed;children=[]]
!STACK 0
java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at org.apache.commons.httpclient.ContentLengthInputStream.read(ContentLengthInputStream.java:170)
    at org.apache.commons.httpclient.ContentLengthInputStream.read(ContentLengthInputStream.java:184)
    at org.apache.commons.httpclient.ChunkedInputStream.exhaustInputStream(ChunkedInputStream.java:369)
    at org.apache.commons.httpclient.ContentLengthInputStream.close(ContentLengthInputStream.java:118)
    at java.io.FilterInputStream.close(Unknown Source)
    at org.apache.commons.httpclient.AutoCloseInputStream.notifyWatcher(AutoCloseInputStream.java:194)
    at org.apache.commons.httpclient.AutoCloseInputStream.close(AutoCloseInputStream.java:158)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.hardClose(AbstractRetrieveFileTransfer.java:331)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.hardClose(HttpClientRetrieveFileTransfer.java:396)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.cancel(HttpClientRetrieveFileTransfer.java:382)
    at org.eclipse.equinox.internal.p2.transport.ecf.FileReader.handleTransferEvent(FileReader.java:173)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.fireTransferReceiveDataEvent(AbstractRetrieveFileTransfer.java:388)
    at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer.fireTransferReceiveDataEvent(HttpClientRetrieveFileTransfer.java:1163)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.handleReceivedData(AbstractRetrieveFileTransfer.java:288)
    at org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer$1.performFileTransfer(AbstractRetrieveFileTransfer.java:173)
    at org.eclipse.ecf.filetransfer.FileTransferJob.run(FileTransferJob.java:73)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SESSION 2014-08-11 23:26:30.697 -----------------------------------------------
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:45:42.431
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:45:42.431
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.431
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.431
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:45:42.441
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:45:42.441
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.441
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:45:42.441
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:58:19.158
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:58:19.158
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.158
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.158
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found

!ENTRY org.eclipse.equinox.p2.operations 4 0 2014-08-12 16:58:19.159
!MESSAGE Operation details
!SUBENTRY 1 org.eclipse.equinox.p2.director 4 1 2014-08-12 16:58:19.159
!MESSAGE Cannot complete the install because one or more required items could not be found.
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.159
!MESSAGE Software being installed: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)
!SUBENTRY 2 org.eclipse.equinox.p2.director 4 0 2014-08-12 16:58:19.159
!MESSAGE Missing requirement: Google Plugin for Eclipse 4.2 3.7.0.v201407290036-rel-r42 (com.google.gdt.eclipse.suite.e42.feature.feature.group 3.7.0.v201407290036-rel-r42)     requires 'org.eclipse.platform.feature.group 3.8.0' but it could not be found
!SESSION 2014-08-12 21:17:29.320 --------------------------------------------    ---
eclipse.buildId=M20120208-0800
java.version=1.7.0_45
java.vendor=Oracle Co    rporation
BootLoader constants:     OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:      -product org.eclipse.epp.package.jee.p    roduct
Command-line argument    s:  -os win32 -ws win32 -arch x86 -prod    uct org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.ui 4 4 2014-08-12 21:17:42.332
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'

!ENTRY org.eclipse.ui 4 0 2014-08-12 21:17:42.334
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.ExceptionInInitializerError
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    ... 51 more
Caused by: java.lang.IllegalStateException: No suitable oauthClientProvider extension point found
    at com.google.gdt.eclipse.login.GoogleLogin.getClientIdAndSecretFromExtensionPoints(GoogleLogin.java:104)
    at com.google.gdt.eclipse.login.GoogleLogin.<clinit>(GoogleLogin.java:77)
    ... 58 more
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2014-08-12 21:17:42.337
!MESSAGE Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
!STACK 0
java.lang.ExceptionInInitializerError
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.IllegalStateException: No suitable oauthClientProvider extension point found
    at com.google.gdt.eclipse.login.GoogleLogin.getClientIdAndSecretFromExtensionPoints(GoogleLogin.java:104)
    at com.google.gdt.eclipse.login.GoogleLogin.<clinit>(GoogleLogin.java:77)
    ... 58 more

!ENTRY org.eclipse.ui.workbench 4 2 2014-08-12 21:17:42.338
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
    at org.eclipse.jface.action.ControlContribution.computeWidth(ControlContribution.java:54)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:100)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$68.runWithException(Workbench.java:3664)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

!ENTRY org.eclipse.ui 4 4 2014-08-12 21:17:42.521
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'

!ENTRY org.eclipse.ui 4 0 2014-08-12 21:17:42.521
!MESSAGE Class load Failure: 'com.google.gdt.eclipse.login.ui.LoginTrimContribution'
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "com.google.gdt.eclipse.login" was unable to instantiate class "com.google.gdt.eclipse.login.ui.LoginTrimContribution".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createContributionItem(DynamicToolBarContributionItem.java:183)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.getContributionItem(DynamicToolBarContributionItem.java:176)
    at org.eclipse.ui.internal.menus.DynamicToolBarContributionItem.createControl(DynamicToolBarContributionItem.java:278)
    at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:97)
    at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:353)
    at org.eclipse.jface.action.ToolBarManager.createControl(ToolBarManager.java:111)
    at org.eclipse.ui.internal.menus.TrimContributionManager$ToolBarTrimProxy.dock(TrimContributionManager.java:88)
    at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:265)
    at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3874)
    at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3885)
    at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1157)
    at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:623)
    at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:300)
    at org.eclipse.ui.internal.WorkbenchWindow.createContents(WorkbenchWindow.java:1043)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.ui.internal.Workbench$22.runWithException(Workbench.java:1216)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.gdt.eclipse.login.GoogleLogin
    at com.google.gdt.eclipse.login.ui.LoginTrimContribution.<init>(LoginTrimContribution.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)


问:
How to draw a new bitmap every time the screen is pressed
I am new to android programing. I am trying to draw a new bitmap image every time the user touches the screen. With the current code right now, all it does is change where the bitmap is at. It doesn't make a new one. How could I make a new one?? Here is the code:

```<code> public class MainDrawingView extends View {

    public float eventX;
    public float eventY;

    public AlertDialog.Builder alertThing;

    Context context = getContext();
   //Bitmaps
   public Bitmap redSquare;

    public String x;
    public String y;
   //Colors
   public boolean red = false;
   public boolean blue = false;
   //Squares
   public boolean topRight = false;
    public boolean topLeft = false;
    public boolean bottomLeft  = false;
    public boolean bottomRight = false;

    public int width = context.getResources().getDisplayMetrics().widthPixels;
    public int height = context.getResources().getDisplayMetrics().heightPixels;
    public int center  = height/2;
    public int widthDiv = width/2;

    private Paint paint  = new Paint();
    private Point pointStart  = new Point();
    private Point pointEnd =  new Point();

    public MainDrawingView(Context context, AttributeSet attrs){
        super(context, attrs);
        paint.setAntiAlias(true);
        paint.setStrokeWidth(5f);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);

        alertThing = new AlertDialog.Builder(context);

        //define bitmap
        redSquare = BitmapFactory.decodeResource(getResources(), R.drawable.red);

    }

    @Override
    public void onDraw(Canvas canvas){
        //canvas.drawPath(path, paint);
       canvas.drawLine(pointStart.x, pointStart.y, pointEnd.x, pointEnd.y,paint);
       //Makes a straight line go through the center of the screen.
       canvas.drawLine(0,height/2.5f, width,height/2.5f,paint);
       //Makes a straight line go up and down.
        canvas.drawLine(width/2.3f,0, width/2.3f, height,paint);

        //Chnages the square colors.

      //  top left combo
        if(topLeft){
         if(red){
             Toast.makeText(context,"jgjgjgjgjgjgjgjgjjg", Toast.LENGTH_SHORT).show();

            new Drawings(redSquare, canvas, eventX, eventY);

         }
        }

    }

    @Override
    public boolean onTouchEvent(MotionEvent event){
        //Gets the coords of the tap

         eventX = event.getX();
         eventY = event.getY();

        int pointX = Math.round(eventX);
        int pointY = Math.round(eventY);

        x = String.valueOf(eventX);
        y = String.valueOf(eventY);

        //This is the top left "square"
        if(eventY < center && eventX < widthDiv ){
            alertThing.setTitle("edit square");
            alertThing.setMessage("please choose an option");
            alertThing.setPositiveButton("red", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    topLeft = true;
                    red = true;

                    invalidate();

                }
            });
            alertThing.setNeutralButton("Chnange color to blue", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

            alertThing.create();
            alertThing.show();
        }

        Toast.makeText(context, "center is :" +x, Toast.LENGTH_SHORT ).show();

        switch(event.getAction()){

            case MotionEvent.ACTION_DOWN:
                //Sets a new starting point
             pointStart.set(pointX,pointY);

               return true;

            case MotionEvent.ACTION_UP:
                //Contects the points
              pointEnd.set(pointX,pointY);
                break;

            default:
                return false;
        }
        invalidate();
        return true;
    }

}
</code>```

Here is the Drawings class that draws the bitmaps:

```<code>public class Drawings {

  public Drawings(Bitmap bitmap, Canvas canvas,float x, float y){

       canvas.drawBitmap(bitmap, x,y,null);

    }
}
</code>```

答:
You really should see what canvas.drawBitmap does. Of course it changes the position, since the touch position changes too.

You create a new bitmap just like you did it when defining bitmap.

But creating new objects in the onDraw will be very slow.

Body:
I am new to android programing. I am trying to draw a new bitmap image every time the user touches the screen. With the current code right now, all it does is change where the bitmap is at. It doesn't make a new one. How could I make a new one?? Here is the code:

 public class MainDrawingView extends View {

    public float eventX;
    public float eventY;

    public AlertDialog.Builder alertThing;

    Context context = getContext();
   //Bitmaps
   public Bitmap redSquare;

    public String x;
    public String y;
   //Colors
   public boolean red = false;
   public boolean blue = false;
   //Squares
   public boolean topRight = false;
    public boolean topLeft = false;
    public boolean bottomLeft  = false;
    public boolean bottomRight = false;

    public int width = context.getResources().getDisplayMetrics().widthPixels;
    public int height = context.getResources().getDisplayMetrics().heightPixels;
    public int center  = height/2;
    public int widthDiv = width/2;

    private Paint paint  = new Paint();
    private Point pointStart  = new Point();
    private Point pointEnd =  new Point();

    public MainDrawingView(Context context, AttributeSet attrs){
        super(context, attrs);
        paint.setAntiAlias(true);
        paint.setStrokeWidth(5f);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);

        alertThing = new AlertDialog.Builder(context);

        //define bitmap
        redSquare = BitmapFactory.decodeResource(getResources(), R.drawable.red);

    }

    @Override
    public void onDraw(Canvas canvas){
        //canvas.drawPath(path, paint);
       canvas.drawLine(pointStart.x, pointStart.y, pointEnd.x, pointEnd.y,paint);
       //Makes a straight line go through the center of the screen.
       canvas.drawLine(0,height/2.5f, width,height/2.5f,paint);
       //Makes a straight line go up and down.
        canvas.drawLine(width/2.3f,0, width/2.3f, height,paint);

        //Chnages the square colors.

      //  top left combo
        if(topLeft){
         if(red){
             Toast.makeText(context,"jgjgjgjgjgjgjgjgjjg", Toast.LENGTH_SHORT).show();

            new Drawings(redSquare, canvas, eventX, eventY);

         }
        }

    }

    @Override
    public boolean onTouchEvent(MotionEvent event){
        //Gets the coords of the tap

         eventX = event.getX();
         eventY = event.getY();

        int pointX = Math.round(eventX);
        int pointY = Math.round(eventY);

        x = String.valueOf(eventX);
        y = String.valueOf(eventY);

        //This is the top left "square"
        if(eventY < center && eventX < widthDiv ){
            alertThing.setTitle("edit square");
            alertThing.setMessage("please choose an option");
            alertThing.setPositiveButton("red", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    topLeft = true;
                    red = true;

                    invalidate();

                }
            });
            alertThing.setNeutralButton("Chnange color to blue", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

            alertThing.create();
            alertThing.show();
        }

        Toast.makeText(context, "center is :" +x, Toast.LENGTH_SHORT ).show();

        switch(event.getAction()){

            case MotionEvent.ACTION_DOWN:
                //Sets a new starting point
             pointStart.set(pointX,pointY);

               return true;

            case MotionEvent.ACTION_UP:
                //Contects the points
              pointEnd.set(pointX,pointY);
                break;

            default:
                return false;
        }
        invalidate();
        return true;
    }

}

Here is the Drawings class that draws the bitmaps:

public class Drawings {

  public Drawings(Bitmap bitmap, Canvas canvas,float x, float y){

       canvas.drawBitmap(bitmap, x,y,null);

    }
}