问:
Make colorbar compatible with gradient bar plot values
I want to make the values I plot to be compatible with the colorbar values. How can I do this? See more details below.

y1, y2, y3 values are : [-1.7  -1.62 -1.53 -1.43 -1.32 -1.2  -1.09 -0.97 -0.85],
 [-1.43 -1.28 -1.09 -0.88 -0.66 -0.44 -0.21  0.03  0.27], [-3.65 -3.58 -3.48 -3.38 -3.27 -3.16 -3.04 -2.92 -2.8 ]

```<code>import matplotlib.pyplot as plt
import numpy as np

#plot
fig = plt.figure(figsize=(9.6,6), dpi=300, linewidth=3.0)
ax = fig.add_subplot(311)
y1 = y.transpose()   #y should be the first data I gave out in the beginning
gradient = [ y1,y1 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax.set_xticklabels(data[list[1]])

ax2 = fig.add_subplot(312)
y2 = y.transpose()  #y should be the second data I gave out in the beginning
gradient = [ y2,y2 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax2.set_xticklabels(data[list[5]])

ax3 = fig.add_subplot(313)
y3 = y.transpose()  #y should be the third data I gave out in the beginning
gradient = [ y3,y3 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax3.set_xticklabels(data[list[9]])

sm = plt.cm.ScalarMappable(cmap=plt.get_cmap('hot'),norm=plt.Normalize(-6.39,9.29))
sm._A = []
plt.colorbar(sm,ax=[ax,ax2,ax3])
#fig.set_tight_layout(True)       #how can I use this? If I use this it generates a warning and the plot overlaps
plt.savefig('CuxOxi.png',dpi=300,format='png', orientation='landscape')
</code>```

As you can see from the graph, the colorbar ranges from -6.39 to 9.29. Each subplot ranges only a fraction of the complete colorbar range. How can I make for example -1.62 to -1.2 to have the color range as defined in the colorbar (which is mostly red)

答:
In each plot, you can add the vmin and vmax options to the plt.imshow function in order to set the color scale min and max for that plot.  You can define these to be the same for each plot so that they all have the same scale.

```<code>vmin = -6
vmax = 9

plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'),vmin=vmin,vmax=vmax)
</code>```

Body:
I want to make the values I plot to be compatible with the colorbar values. How can I do this? See more details below.

y1, y2, y3 values are : [-1.7  -1.62 -1.53 -1.43 -1.32 -1.2  -1.09 -0.97 -0.85],
 [-1.43 -1.28 -1.09 -0.88 -0.66 -0.44 -0.21  0.03  0.27], [-3.65 -3.58 -3.48 -3.38 -3.27 -3.16 -3.04 -2.92 -2.8 ]

import matplotlib.pyplot as plt
import numpy as np

#plot
fig = plt.figure(figsize=(9.6,6), dpi=300, linewidth=3.0)
ax = fig.add_subplot(311)
y1 = y.transpose()   #y should be the first data I gave out in the beginning
gradient = [ y1,y1 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax.set_xticklabels(data[list[1]])

ax2 = fig.add_subplot(312)
y2 = y.transpose()  #y should be the second data I gave out in the beginning
gradient = [ y2,y2 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax2.set_xticklabels(data[list[5]])

ax3 = fig.add_subplot(313)
y3 = y.transpose()  #y should be the third data I gave out in the beginning
gradient = [ y3,y3 ]
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'))
ax3.set_xticklabels(data[list[9]])

sm = plt.cm.ScalarMappable(cmap=plt.get_cmap('hot'),norm=plt.Normalize(-6.39,9.29))
sm._A = []
plt.colorbar(sm,ax=[ax,ax2,ax3])
#fig.set_tight_layout(True)       #how can I use this? If I use this it generates a warning and the plot overlaps
plt.savefig('CuxOxi.png',dpi=300,format='png', orientation='landscape')

As you can see from the graph, the colorbar ranges from -6.39 to 9.29. Each subplot ranges only a fraction of the complete colorbar range. How can I make for example -1.62 to -1.2 to have the color range as defined in the colorbar (which is mostly red)

Body:
In each plot, you can add the vmin and vmax options to the plt.imshow function in order to set the color scale min and max for that plot.  You can define these to be the same for each plot so that they all have the same scale.

vmin = -6
vmax = 9

plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('hot'),vmin=vmin,vmax=vmax)


来源: stackexchange

问:
Java System Clock Independent Scheduling/Pausing
I need a way to pause/sleep a thread in a system clock independent way. Meaning, that if I want a Thread to weak up in dT msecs it must do so also if the system time changes significantly during this time. I am not so much interested in accuracy in msecs and more in principle that it will work.

TimerTasks are not an option since they work on absolute time.

答:
Tricky.... it's tough to know if the system clock is even being used for any given strategy. However, your avoidance of the clock is because the time might be changed during the thread pause, but System.nanoTime() is independent of the current time since it is purely the number of nanoseconds since the JVM started. Accordingly, if the pause strategy uses nanos, one might assume that the pause periods will retain accuracy through system clock time changes.  Perhaps Thread.join(0, nanos) called in a loop:

```<code>public static void pause(long ms) throws InterruptedException {
   long final ZERO = 0L;
   int final MAX_NANOS = 999999;
   for(int i = 0; i < ms+1; i++) {
      Thread.currentThread().join(ZERO, MAX_NANOS);
   }
}
</code>```

I did not test with system clock changes, but it appears to run within a .004% deviation.

ContentLicense: CC BY-SA 3.0

Body:
Tricky.... it's tough to know if the system clock is even being used for any given strategy. However, your avoidance of the clock is because the time might be changed during the thread pause, but System.nanoTime() is independent of the current time since it is purely the number of nanoseconds since the JVM started. Accordingly, if the pause strategy uses nanos, one might assume that the pause periods will retain accuracy through system clock time changes.  Perhaps Thread.join(0, nanos) called in a loop:

public static void pause(long ms) throws InterruptedException {
   long final ZERO = 0L;
   int final MAX_NANOS = 999999;
   for(int i = 0; i < ms+1; i++) {
      Thread.currentThread().join(ZERO, MAX_NANOS);
   }
}

I did not test with system clock changes, but it appears to run within a .004% deviation.

ContentLicense: CC BY-SA 2.5


问:
how to store form validation errors in an array
If I have some basic form validations, (just using empty() for simplicities sake) and want to put those error messages into an array, how would I achieve this? </p>

```<code> $errors = array();
 $response = array();

if(empty($_POST['name'])) {

    $errors['name'] = "Name required";
}

if(empty($_POST['email'])) {

    $errors['email'] = "Email required";
}

$response['errors'] = $errors;

if(!empty($errors)) {

    $response['success'] = false;
    $response['message'] = "fail";

} else {

    $response['success'] = true;
    $response['message'] = "<div class='alert alert-success'>Success</div>";
}

echo json_encode($response);
}
</code>```

答:
```<code>    $message = [];

if(empty($_POST['name'])) {

array_push($message , "Name required <br />");

}

if(empty($_POST['email'])) {

array_push($message , "Email required <br />");

}

if(!empty($message)) {
foreach ( $message as $str)
echo "<div class='alert alert-danger'>" . $str . "</div>";

} else {
// success

}
</code>```

Body:
If I have some basic form validations, (just using empty() for simplicities sake) and want to put those error messages into an array, how would I achieve this?

 $errors = array();
 $response = array();

if(empty($_POST['name'])) {

    $errors['name'] = "Name required";
}

if(empty($_POST['email'])) {

    $errors['email'] = "Email required";
}

$response['errors'] = $errors;

if(!empty($errors)) {

    $response['success'] = false;
    $response['message'] = "fail";

} else {

    $response['success'] = true;
    $response['message'] = "
Success
";
}

echo json_encode($response);
}


问:
How to use svn+ssh in IntelliJ Windows?
Our SVN server allows ssh connections only. How can I configure IntelliJ on Windows to connect to SVN server using svn+ssh?</p>

答:
In order to connect to SVN using ssh on a Windows machine, you will need to

Generate your ssh private key and upload it to your user allowed keys on the server.

Create a saved PuTTy session to use the private key file.

Download TortoiseSVN Plink to be used as SSH tunnel.

Configure IntelliJ to use TortoiseSVN to connect to your SVN server.

Here are the details of these steps.

1. Generate your private key.

You can use PUTTYGEN to generate the private key.

Then save the key in the .ssh folder in the user home directory.

If you have Windows 10, you can use Bash on Ubuntu on Windows to generate and load your private keys.

```<code>ssh-keygen -t rsa
</code>```

This will generate the file  ~/.ssh/id_rsa

Then load the key to the server

```<code>ssh-copy-id  amr@example.com
</code>```

The final step is to move the generated file from the Ubuntu subsystem path to your home directory in windows.

```<code>cp ~/.ssh/id_rsa  /mnt/c/Users/amr/.ssh/
</code>```

You still need to convert the key from OpenSSH to PPK format using the PUTTYGEN tool. From the tool load the file and then save the private key again in the PPK format.

2. Create a saved PuTTy session and configure it to use your private key.

Create a new session in PuTTY for login into the SVN server and change the setting of SSH/Auth to point to the private key file

3. Use Tortoise SVN Plink as the ssh tunnel

Download and install Tortoise SVN. It has a command line tool named TortoisePlink which is based on puTTY. We will use plink as the SSH tunnel for SVN.

4. Configure IntelliJ to use this SSH tunnel for Subversion.

Go to File/Settings/Version Control/Subversion then select SSH settings tab.

Select Subversion config

make sure SSH tunnel is set to $SVN_SSH ssh -q
then add the path to TortoisPlink as in the picture. Make sure to skip backslashes.

Then, you are good to go.

Title: How to use svn+ssh in IntelliJ Windows?

Body:
In order to connect to SVN using ssh on a Windows machine, you will need to

Generate your ssh private key and upload it to your user allowed keys on the server.

Create a saved PuTTy session to use the private key file.

Download TortoiseSVN Plink to be used as SSH tunnel.

Configure IntelliJ to use TortoiseSVN to connect to your SVN server.

Here are the details of these steps.

1. Generate your private key.

You can use PUTTYGEN to generate the private key.

Then save the key in the .ssh folder in the user home directory.

If you have Windows 10, you can use Bash on Ubuntu on Windows to generate and load your private keys.

ssh-keygen -t rsa

This will generate the file  ~/.ssh/id_rsa

Then load the key to the server

ssh-copy-id  amr@example.com

The final step is to move the generated file from the Ubuntu subsystem path to your home directory in windows.

cp ~/.ssh/id_rsa  /mnt/c/Users/amr/.ssh/

You still need to convert the key from OpenSSH to PPK format using the PUTTYGEN tool. From the tool load the file and then save the private key again in the PPK format.

2. Create a saved PuTTy session and configure it to use your private key.

Create a new session in PuTTY for login into the SVN server and change the setting of SSH/Auth to point to the private key file

3. Use Tortoise SVN Plink as the ssh tunnel

Download and install Tortoise SVN. It has a command line tool named TortoisePlink which is based on puTTY. We will use plink as the SSH tunnel for SVN.

4. Configure IntelliJ to use this SSH tunnel for Subversion.

Go to File/Settings/Version Control/Subversion then select SSH settings tab.

Select Subversion config

make sure SSH tunnel is set to $SVN_SSH ssh -q
then add the path to TortoisPlink as in the picture. Make sure to skip backslashes.

Then, you are good to go.


问:
Laravel - get all records that contains a specific string
I'm trying to get a query that gives me every record that contains a specific string in a specific column( no matter if the first letter is uppercase or lowercase.

For example: The string I'm passing is test

And I have 30 records in my database. 5 of them have do contain test ( lowercase ) and 5 of them Test ( uppercase ) . The 20 other records are useless, so I don't need them.

I've got some help yesterday but couldn't make it like I really want it and the output is also wrong.

Thats the code:

```<code>$search = $request['search'];
        $usergroups = Usergroups::where('name', 'like', '%' . str_slug($search, ' ') . '%')->simplePaginate(3);
</code>```

$search is a variable that contains the string I want to search for.

If I want to search for Test, I get just every record back. No matter if it contains Test, test, or unicorn bla bla. I get just everything back.

Does someone knows a way to fix that? I've tried to write a custom paginate class but that haven't worked for me.

答:
Only use orWhere when you want to chain multiple where statements for your record fetching.

```<code>$users = \App\UserGroup::where('name', 'LIKE', '%Test%')->get();
</code>```

I think the issue might come with the pagination.
I added this to get pagination working for my 2 records named Test and test

```<code>$users = \App\UserGroup::where('name', 'LIKE', '%Test%')->simplePaginate(1);
</code>```

If you need to show the results on a view using blade, this might be helpful:

https://laravel.com/docs/5.4/pagination#displaying-pagination-results

Body:
I'm trying to get a query that gives me every record that contains a specific string in a specific column( no matter if the first letter is uppercase or lowercase.

For example: The string I'm passing is test

And I have 30 records in my database. 5 of them have do contain test ( lowercase ) and 5 of them Test ( uppercase ) . The 20 other records are useless, so I don't need them.

I've got some help yesterday but couldn't make it like I really want it and the output is also wrong.

Thats the code:

$search = $request['search'];
        $usergroups = Usergroups::where('name', 'like', '%' . str_slug($search, ' ') . '%')->simplePaginate(3);

$search is a variable that contains the string I want to search for.

If I want to search for Test, I get just every record back. No matter if it contains Test, test, or unicorn bla bla. I get just everything back.

Does someone knows a way to fix that? I've tried to write a custom paginate class but that haven't worked for me.

Body:
Only use orWhere when you want to chain multiple where statements for your record fetching.

$users = \App\UserGroup::where('name', 'LIKE', '%Test%')->get();

I think the issue might come with the pagination.
I added this to get pagination working for my 2 records named Test and test

$users = \App\UserGroup::where('name', 'LIKE', '%Test%')->simplePaginate(1);

If you need to show the results on a view using blade, this might be helpful:

https://laravel.com/docs/5.4/pagination#displaying-pagination-results


问:
CouchDB heart-beat time-out
My CouchDB (production) server is sometimes shut down, without my wanting it to. While inspecting logs I noticed Erlang/CouchDB (one or the other) sends a heart beat, and that heart beat is monitored. When a time-out occurs, the server is brutally killed (couchdb -k). This is almost always unwanted behaviour, definitely on a production server.

I've come across this issue, which states the same and indicates this mostly occurs during heavy server loads, something I noticed also.

I'm looking for a solution to keep my server running, but to do that I need to know more about this behaviour. Unfortunately both the CouchDB wiki and the guide don't give much information about this (only the parameter in the changes API).

Can someone provide more info about this?

答:
Most likely heart is the heart launched when erlang vm starts up.

Take a look at heart switch here http://erlang.org/doc/man/erl.html and its documentation here http://erlang.org/doc/man/heart.html.

Now, you can either give a link to couch repo you use, so we can find a script with 'erl something -heart' or grep it out yourself.

I am not sure what is the status of couch build system.. do you use cloudant version or pure apache?

Title: CouchDB heart-beat time-out


问:
Can't get xdebug to send back information: PhpStorm+xdebug+ec2-linux
So according to my php.ini and PhpStorm (validate debugger configuration on web server) xdebug is perfectly installed and configured and PhpStorm is able to receive and send info to xdebug on the remote server.

YET, when I add break points and clearly reached those break points, I don't get any debugger info like variables and their contents. I have no idea what I'm still missing but here is my phpinfo() screenshot:

EDIT
I also have installed in chrome browser the extension the xdebug helper.  which is enabled.  Here is my xdebug log:

```<code>    Log opened at 2017-06-27 04:02:49
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
W: Creating socket for '<my address>:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-06-27 04:02:49

Log opened at 2017-06-27 04:04:58
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:04:59

Log opened at 2017-06-27 04:05:22
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:05:22

Log opened at 2017-06-27 04:05:58
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:05:58

Log opened at 2017-06-27 04:06:05
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:06:05
</code>```

EDIT
Here is the javascript for the phpstorm bookmark that I use to activate a xdebug session:

```<code>javascript:(/** @version 0.5.2 */function() {document.cookie='XDEBUG_SESSION='+'PHPSTORM'+';path=/;';})()
</code>```

EDIT

Here is screenshot of my resource monitor on windows that indeed shows phpstorm.exe is listening on port 9000 and that port is open for communication:

答:
It looks like Xdebug can't connect to IP address <myaddress> on port
9000. Which should be the IP address of your Windows machine. It can be
a Windows Firewall (or "Defender") blocking it, or perhaps there is
something else that blocks the connection. A time-out likely points this
more towards the firewall.

Body:
So according to my php.ini and PhpStorm (validate debugger configuration on web server) xdebug is perfectly installed and configured and PhpStorm is able to receive and send info to xdebug on the remote server.

YET, when I add break points and clearly reached those break points, I don't get any debugger info like variables and their contents. I have no idea what I'm still missing but here is my phpinfo() screenshot:

EDIT
I also have installed in chrome browser the extension the xdebug helper.  which is enabled.  Here is my xdebug log:

    Log opened at 2017-06-27 04:02:49
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
W: Creating socket for '<my address>:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-06-27 04:02:49

Log opened at 2017-06-27 04:04:58
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:04:59

Log opened at 2017-06-27 04:05:22
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:05:22

Log opened at 2017-06-27 04:05:58
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:05:58

Log opened at 2017-06-27 04:06:05
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to <my address>:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-06-27 04:06:05

EDIT
Here is the javascript for the phpstorm bookmark that I use to activate a xdebug session:

javascript:(/** @version 0.5.2 */function() {document.cookie='XDEBUG_SESSION='+'PHPSTORM'+';path=/;';})()

EDIT

Here is screenshot of my resource monitor on windows that indeed shows phpstorm.exe is listening on port 9000 and that port is open for communication:


问:
Using Terraform with docker-compose and nginx-proxy
Has anyone tried using all these tools together?

I'm currently using nginx-proxy and docker-compose for a four-container solution.

I'm now trying to make deployment better/faster/cheaper and think terraform might be the piece I'm now looking for.

My question is - does terraform work with docker-compose? Or is there too much overlap between them?

Thanks for any advice!

答:
You can use Terraform provider as already suggested but if you want to stick to docker-compose for any reason you can also create your docker-compose file and run the necessary commands with user-data. Take a look to template_file  and template_cloudinit_config

Example

nginx.tpl

```<code>#cloud-config
write_files:
 - content: |
        version: '2'
        services:
            nginx:
              image: nginx:latest
   path: /opt/docker-compose.yml
runcmd:
 - 'docker-compose -f /opt/docker-compose.yml up -d'
</code>```

nginx.tf

```<code>data "template_file" "nginx" {
    template = "${file("nginx.tpl")}"
}

resource "aws_instance" "nginx" {
    instance_type = "t2.micro"
    ami = "ami-xxxxxxxx"

    user_data = "${data.template_file.nginx.rendered}"
}
</code>```

I use AWS but this should work with any provider supporting user-data and a box with cloud-init. Also this approach is suitable for autoscaling.

Body:
You can use Terraform provider as already suggested but if you want to stick to docker-compose for any reason you can also create your docker-compose file and run the necessary commands with user-data. Take a look to template_file  and template_cloudinit_config

Example

nginx.tpl

#cloud-config
write_files:
 - content: |
        version: '2'
        services:
            nginx:
              image: nginx:latest
   path: /opt/docker-compose.yml
runcmd:
 - 'docker-compose -f /opt/docker-compose.yml up -d'

nginx.tf

data "template_file" "nginx" {
    template = "${file("nginx.tpl")}"
}

resource "aws_instance" "nginx" {
    instance_type = "t2.micro"
    ami = "ami-xxxxxxxx"

    user_data = "${data.template_file.nginx.rendered}"
}

I use AWS but this should work with any provider supporting user-data and a box with cloud-init. Also this approach is suitable for autoscaling.


问:
VSTS Release Manager copy only specific files
I want to download a specific folder from my team project in VSTS and copy it to a server on premise. I've setup the vsts agent and it can copy files just fine by using the "Windows Machine File Copy", but my problem is the agent downloads my whole team project starting from the root.

In Artifacts when I choose Link an artifact source and under type choose Team Foundation Version Control, under Source (repository) I can only choose my team project $/myTeamProject in the dropdown list. I'm not able to provide a path in VSTS like $/myTeamProjet/Main/subfolder.

Is this the wrong approach? I basically want to copy some files from a subfolder in my team project in VSTS to a on premise machine, without downloading everything from the whole root folder ($/myTeamProject). It takes forever when I trigger a Release with a singe task that copies files. How can the agent map only a specific folder and not the whole root folder?

答:
My opinion is that it's not a great approach. Your build should be publishing a set of artifacts that represents a full set of deployable bits that will remain static as you deploy them through a pipeline.

Think of this scenario: You have a release definition with a pipeline defined that goes Dev -> QA -> Prod.

You deploy to Dev. Your release definition pulls in Changeset 1234 from source control.

A few hours later, you deploy to QA. Your release definition pulls in Changeset 1234.

Someone changes some source code. You go to deploy to Prod. Your release definition pulls in Changeset 1235. Now you're deploying some stuff that hasn't been tested in a lower environment. You've just drastically increased the likelihood of a problem.

Same scenario applies if you ever want to redeploy an old version to try to repro a bug.

In short: publish that folder as an artifact as part of your build process.


问:
Unexpected error while executing
I searched for this question already but there were no answers that worked for me. Every time I debug my app it gives me this error.

```<code>Unexpected error while executing: am start -n "com.example.maomei.passusersystem/com.example.maomei.passusersystem.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Error while Launching activity
</code>```

Here is my MainActivity code:

```<code>public class MainActivity extends AppCompatActivity {

    TextView textView1;
    Button button1;

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

        TextView textView1 = (TextView) findViewById(R.id.textView1);
        Button button1 = (Button) findViewById(R.id.button1);

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()){
                    case R.id.button1:

                        Intent myIntent = new Intent(MainActivity.this, Main2Activity.class);
                        MainActivity.this.startActivity(myIntent);

                    }

            }

        });
    }
}
</code>```

and my Manifest code:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maomei.passusersystem">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="com.example.maomei.passusersystem.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Main2Activity"
            android:label="@string/title_activity_main2"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".Main4Activity"
            android:label="@string/title_activity_main4"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".Main5Activity"
            android:label="@string/title_activity_main5"
            android:theme="@style/AppTheme.NoActionBar">

        </activity>
    </application>
</manifest>
</code>```

答: Try changing the android:name attribute of MainActivity in your manifest file to just .MainActivity

Title: Unexpected error while executing

Body:
I searched for this question already but there were no answers that worked for me. Every time I debug my app it gives me this error.

Unexpected error while executing: am start -n "com.example.maomei.passusersystem/com.example.maomei.passusersystem.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Error while Launching activity

Here is my MainActivity code:

public class MainActivity extends AppCompatActivity {

    TextView textView1;
    Button button1;

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

        TextView textView1 = (TextView) findViewById(R.id.textView1);
        Button button1 = (Button) findViewById(R.id.button1);

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()){
                    case R.id.button1:

                        Intent myIntent = new Intent(MainActivity.this, Main2Activity.class);
                        MainActivity.this.startActivity(myIntent);

                    }

            }

        });
    }
}

and my Manifest code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maomei.passusersystem">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="com.example.maomei.passusersystem.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Main2Activity"
            android:label="@string/title_activity_main2"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".Main4Activity"
            android:label="@string/title_activity_main4"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".Main5Activity"
            android:label="@string/title_activity_main5"
            android:theme="@style/AppTheme.NoActionBar">

        </activity>
    </application>
</manifest>


问:
R: Making a score meter / gradient arc
I am trying to recreate a graph that was made in excel. It is basically a score meter or gradient arc which shows the deprivation decile of a certain area. Therefore, it is a gradient meter from 10 to 1 (Red to Green) with a certain value which indicates the deprivation decile. Something like this image.

Deprivation in area gradient arc

I need to create the similar graph in R which would just allow me to change the deprivation decile and the graph would show up. I tried to play with colorRampPalette and plot but could not find a way to do this. I don't really mind whether the graph is an arc or a flat one.

PS: I tried to find a better way of visually represent this sort of data but could not really find any. If you think of anything that is better suited, feel free to point it out to me.

Thanks

答:
I'm not exatcly sure if this is what you are looking for, and of course you can modify to suit your purposes but here's a small bit of code to get you started. It builds a horizontal meter which goes from 0 to 100 and all you have to do is select the value val (here 60) and the text sText (here Harborough 003E).

```<code>library(ggplot2)
val <- 60 ; sText <- "Harborough 003E"

df <- data.frame(y = seq(0, 100, by = 1), x = 1)
df.labs <- data.frame(y = c(0, 100, val),
                      lab = c("Most Deprived",
                              "Least Deprived",
                              sText))

ggplot(df, aes(x = x, y = y, fill = y)) +
  geom_tile() +
  geom_hline(yintercept = val, colour = "blue", size = 1) +
  geom_text(data = df.labs, aes(x = 1, y = y, label = lab), hjust = c(0, 1, 0.5)) +
  scale_fill_gradient(low = "red", high = "green", guide = FALSE) +
  coord_flip() +
  theme_void() +
  theme(aspect.ratio = 0.1)
</code>```

Of course you can manipulate it asyou see fit, adding tick marks, values, titles or whatever else you need.

The resulting plot is:

I hope this helps.

Title: R: Making a score meter / gradient arc

Body:
I'm not exatcly sure if this is what you are looking for, and of course you can modify to suit your purposes but here's a small bit of code to get you started. It builds a horizontal meter which goes from 0 to 100 and all you have to do is select the value val (here 60) and the text sText (here Harborough 003E).

library(ggplot2)
val <- 60 ; sText <- "Harborough 003E"

df <- data.frame(y = seq(0, 100, by = 1), x = 1)
df.labs <- data.frame(y = c(0, 100, val),
                      lab = c("Most Deprived",
                              "Least Deprived",
                              sText))

ggplot(df, aes(x = x, y = y, fill = y)) +
  geom_tile() +
  geom_hline(yintercept = val, colour = "blue", size = 1) +
  geom_text(data = df.labs, aes(x = 1, y = y, label = lab), hjust = c(0, 1, 0.5)) +
  scale_fill_gradient(low = "red", high = "green", guide = FALSE) +
  coord_flip() +
  theme_void() +
  theme(aspect.ratio = 0.1)

Of course you can manipulate it asyou see fit, adding tick marks, values, titles or whatever else you need.

The resulting plot is:

I hope this helps.


问:
How to map the root url to swagger view in .net core
My application is in .net core.

I want to map the root URL http://localhost:<port>/ to swagger view.
I tried by setting the default route, as specified in below link, but it doesn't work.

c# mvc how to map the root url to a specific view

I think it's because of I am using attribute routing.
But is there any way, I can map root URL to Swagger view.

答:
To map the root url you'll have to:

Create a HomeController on your API project and add the following code.

```<code>[Route("")]
[HttpGet]
[AllowAnonymous] (Only if you have authorization going on)
public IActionResult Index()
{
    return Redirect("/swagger/ui/index.html");
}
</code>```

After that, you have to open the folder properties on your project and update the section profile on file launchSettings.json as follows.

"profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "odin": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }```

Body:
To map the root url you'll have to:

Create a HomeController on your API project and add the following code.

[Route("")]
[HttpGet]
[AllowAnonymous] (Only if you have authorization going on)
public IActionResult Index()
{
    return Redirect("/swagger/ui/index.html");
}

After that, you have to open the folder properties on your project and update the section profile on file launchSettings.json as follows.

"profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "odin": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }


问:
short list of recently changed pages in mediawiki
I'm using mediawiki to run a wiki for my (relatively small <10 users) team and would like to know if its possible to get a short list of, say, the last 5 changed pages to appear in the side bar.  I know I can go to recent changes page, but my users are used to seeing a list of the most recent changed pages on every page.

Thanks

答:
I saw here that you got a hack to put wikitext into the sidebar: http://www.mwusers.com/forums/showthread.php?15842-Show-recent-changes-in-sidebar

Try transcluding the recent changes into a template, then putting that template in the sidebar.


问:
Setting a column default value in the kendo ui grid to DateTime.Now
I wish to make a grid within my visual studio program to display DateTime.now as a default but it's not working.

The column within the Kendo grid:

```<code>columns.Bound(c => c.CurrentDate).EditorTemplateName("Date").Format("{0:dd/MM/yy}");
</code>```

The declaration within my model:

```<code>public DateTime CurrentDate { get; set; }
</code>```

When I load the web page the value of the text box within the column is set to the current date but the value is not displayed.

My Kendo UI Grid Code:

```<code>@(Html.Kendo().Grid<Kendo_UI_Bootstrap_Integration.Models.EID>()
        .Name("EIDGrid")
        .Columns(
            columns =>
            {

                columns.Bound(c => c.Breed);
                columns.Bound(c => c.Gender);
                columns.Bound(c => c.AnimalId);
                columns.Bound(c => c.EIDDate).EditorTemplateName("Date").ClientTemplate(DateTime.Now.ToString("dd/MM/yy"));//.ClientTemplate(DateTime.Now.ToString()).Format("{0:dd/MM/yy}").EditorTemplateName("Date");//.EditorTemplateName("Date")
                columns.Bound(c => c.EIDNum);
                columns.Bound(c => c.BatchNum);
            }
    )
    .Scrollable(s => s.Height("350px"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
    .Pageable()
    .DataSource(datasource => datasource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.SireGuid);
            //model.Field(p => p.SireGuid).DefaultValue(Guid.Empty);
            //model.Id(p => p.EIDDate);
            //model.Field(p => p.EIDDate).Editable(true);

        })
        .PageSize(100)
        .Batch(true)
        .Sort(s => s.Add("Name"))
    ) )
</code>```

My Model code:

```<code>using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;

namespace Kendo_UI_Bootstrap_Integration.Models {

    public class EID
    {

        public string Breed { get; set; }
        public string Gender { get; set; }
        public string AnimalId { get; set; }
        public int EIDNum { get; set; }
        public int BatchNum { get; set; }

        public DateTime EIDDate { get; set; }

        public int ClusterIndex
        {
            get; set;
        }
        public System.Guid SireGuid { get; set; }
    }
 }
</code>```

My Controller Code:

```<code>using System;
using System.Collections.Generic;
using System.Linq; using System.Web;
using System.Web.Mvc;

namespace Kendo_UI_Bootstrap_Integration.Controllers {
    public class EidController : Controller
    {
        // GET: Eid
        public ActionResult EidView ()
        {
            return View();
        }
    }
}
</code>```

答:
Try something like this:

Model:

```<code>public class Eid
{
    public string Breed { get; set; }
    public DateTime EIDDate { get; set; } = DateTime.Now;
    public string SireGuid { get; set; }
}
</code>```

MVC wrapper:

```<code>@(Html.Kendo().Grid<KendoUIApp3.Models.Eid>()
    .Name("EIDGrid")
    .Columns(columns =>
    {
        columns.Bound(c => c.Breed);
        columns.Bound(c => c.EIDDate).Format("{0:dd/MM/yy}");
    })
    .Scrollable(s => s.Height("350px"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
    .Pageable()
    .Groupable()
    .Sortable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.SireGuid);
        })
        .Read(read => read.Action("EIDRead", "Home"))
        .PageSize(100)
        .Batch(true)
        .Sort(s => s.Add("Breed"))
    ))
</code>```

Controller:

```<code>public ActionResult EIDRead([DataSourceRequest] DataSourceRequest request)
    {
        var collection = new List<Eid>()
        {
           new Eid
           {
               Breed = "test",
               SireGuid = Guid.NewGuid().ToString()
           }
        };

        return Json(collection.ToDataSourceResult(request));
    }
</code>```

You have to define a way your grid is populated by data. In this case I use .Read function to query controller method EIDRead for rows. Of course you can pass your data directly to the grid, but this method is much easier for maintainance.

ContentLicense: CC BY-SA 4.0

Body:
I wish to make a grid within my visual studio program to display DateTime.now as a default but it's not working.

The column within the Kendo grid:

columns.Bound(c => c.CurrentDate).EditorTemplateName("Date").Format("{0:dd/MM/yy}");

The declaration within my model:

public DateTime CurrentDate { get; set; }

When I load the web page the value of the text box within the column is set to the current date but the value is not displayed.

My Kendo UI Grid Code:

@(Html.Kendo().Grid<Kendo_UI_Bootstrap_Integration.Models.EID>()
        .Name("EIDGrid")
        .Columns(
            columns =>
            {

                columns.Bound(c => c.Breed);
                columns.Bound(c => c.Gender);
                columns.Bound(c => c.AnimalId);
                columns.Bound(c => c.EIDDate).EditorTemplateName("Date").ClientTemplate(DateTime.Now.ToString("dd/MM/yy"));//.ClientTemplate(DateTime.Now.ToString()).Format("{0:dd/MM/yy}").EditorTemplateName("Date");//.EditorTemplateName("Date")
                columns.Bound(c => c.EIDNum);
                columns.Bound(c => c.BatchNum);
            }
    )
    .Scrollable(s => s.Height("350px"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
    .Pageable()
    .DataSource(datasource => datasource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.SireGuid);
            //model.Field(p => p.SireGuid).DefaultValue(Guid.Empty);
            //model.Id(p => p.EIDDate);
            //model.Field(p => p.EIDDate).Editable(true);

        })
        .PageSize(100)
        .Batch(true)
        .Sort(s => s.Add("Name"))
    ) )

My Model code:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;

namespace Kendo_UI_Bootstrap_Integration.Models {

    public class EID
    {

        public string Breed { get; set; }
        public string Gender { get; set; }
        public string AnimalId { get; set; }
        public int EIDNum { get; set; }
        public int BatchNum { get; set; }

        public DateTime EIDDate { get; set; }

        public int ClusterIndex
        {
            get; set;
        }
        public System.Guid SireGuid { get; set; }
    }
 }

My Controller Code:

using System;
using System.Collections.Generic;
using System.Linq; using System.Web;
using System.Web.Mvc;

namespace Kendo_UI_Bootstrap_Integration.Controllers {
    public class EidController : Controller
    {
        // GET: Eid
        public ActionResult EidView ()
        {
            return View();
        }
    }
}

Body:
Try something like this:

Model:

public class Eid
{
    public string Breed { get; set; }
    public DateTime EIDDate { get; set; } = DateTime.Now;
    public string SireGuid { get; set; }
}

MVC wrapper:

@(Html.Kendo().Grid<KendoUIApp3.Models.Eid>()
    .Name("EIDGrid")
    .Columns(columns =>
    {
        columns.Bound(c => c.Breed);
        columns.Bound(c => c.EIDDate).Format("{0:dd/MM/yy}");
    })
    .Scrollable(s => s.Height("350px"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
    .Pageable()
    .Groupable()
    .Sortable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.SireGuid);
        })
        .Read(read => read.Action("EIDRead", "Home"))
        .PageSize(100)
        .Batch(true)
        .Sort(s => s.Add("Breed"))
    ))

Controller:

public ActionResult EIDRead([DataSourceRequest] DataSourceRequest request)
    {
        var collection = new List<Eid>()
        {
           new Eid
           {
               Breed = "test",
               SireGuid = Guid.NewGuid().ToString()
           }
        };

        return Json(collection.ToDataSourceResult(request));
    }

You have to define a way your grid is populated by data. In this case I use .Read function to query controller method EIDRead for rows. Of course you can pass your data directly to the grid, but this method is much easier for maintainance.


问:
resets all Widgets when scrolling up and down?
when ever i move down scroll the widgets refresh . i need to stop refresh

when ever i move down scroll the widgets refresh . i need to stop refresh. the valus of widgets shuld be remain till image button clicked.
 after change values of widgets when i scroll up after down the widgets values reset . the values should be remain as i perform action.

this is refreshing widgets

XML file

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="30dp"
android:textColor="#000"
>

<TextView
    android:id="@+id/text_Lt"
    android:layout_width="30dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="6dp"
    android:gravity="center"
    android:textAlignment="center"
    android:textColor="#000"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    />
<LinearLayout
    android:id="@+id/Teacher_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:orientation="vertical"
    android:textColor="#000"
    >

<TextView
    android:id="@+id/text_teacher_name"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:textColor="#000"
    android:layout_marginTop="10dp"
    />
<Spinner
    android:id="@+id/spinner_teacher_name"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:layout_marginTop="-20dp">
</Spinner>
</LinearLayout>
<LinearLayout
    android:id="@+id/radioButtons"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:orientation="vertical">

    <RadioGroup
        android:id="@+id/radioButton_group_PresentAbsent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <RadioButton
            android:id="@+id/radioButton_present"
            android:layout_width="80dp"
            android:layout_height="25dp"
            android:text="Present"
            android:textSize="12sp"
            />

        <RadioButton
            android:layout_marginTop="3dp"
            android:id="@+id/radioButton_absent"
            android:layout_width="80dp"
            android:layout_height="25dp"
            android:text="Absent"
            android:textSize="12sp"
            />
    </RadioGroup>
</LinearLayout>

<EditText
    android:id="@+id/etxtStartTimePicker"
    android:layout_width="50dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:textSize="11sp"
    android:text="LATE"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"/>
<EditText
    android:id="@+id/etxtEndTimePicker"
    android:layout_width="50dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:textSize="11sp"
    android:text="LEAVE"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    android:visibility="invisible"
    />
<ImageButton
    android:id="@+id/submit_Attendance"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    android:src="@drawable/biit"
    android:visibility="visible"/>
</LinearLayout>
</code>```

after change values of widgets when i scroll up after down the widgets values reset , please help . the values should be remain as i perform action.
Java File

```<code>public class CustomAdapter extends BaseAdapter
{
    private static LayoutInflater inflater = null;
    String[] class_room;
    Context context;
    String[] teacher_name;
    String[] days;
    ArrayAdapter<String> arrayAdapter1;
    Calendar c = Calendar.getInstance();

    public CustomAdapter(teacher_attendance mainActivity, String[] arr, String[] arr1, String[] arr2) {
        // TODO Auto-generated constructor stub
        class_room = arr;
        teacher_name = arr1;
        days=arr2;
        context = mainActivity;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return class_room.length
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        final Holder holder = new Holder();
        final View rowView;

        rowView = inflater.inflate(R.layout.row_layout, null);
        holder.radioButton_Group_PresentAbsent = (RadioGroup) rowView.findViewById(R.id.radioButton_group_PresentAbsent);
        holder.radioButtonPresent = (RadioButton) rowView.findViewById(R.id.radioButton_present);
        holder.txtlt = (TextView) rowView.findViewById(R.id.text_Lt);
        holder.txtteacher = (TextView) rowView.findViewById(R.id.text_teacher_name);
        holder.radioButtonAbsent = (RadioButton) rowView.findViewById(R.id.radioButton_absent);
        holder.etxtStart_time_Picker = (EditText) rowView.findViewById(R.id.etxtStartTimePicker);
        holder.etxtStart_time_Picker.setFocusable(false);
        holder.etxtEnd_time_Picker = (EditText) rowView.findViewById(R.id.etxtEndTimePicker);
        holder.etxtEnd_time_Picker.setFocusable(false);
        holder.txtlt.setText(class_room[position]);
        holder.txtteacher.setText(teacher_name[position]);
        holder.submitAttendance = (ImageButton) rowView.findViewById(R.id.submit_Attendance);
        holder.submitAttendance.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name = (Spinner) rowView.findViewById(R.id.spinner_teacher_name);
        arrayAdapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, teacher_name);
        arrayAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        holder.spinner_teacher_name.setAdapter(arrayAdapter1);
        holder.submitAttendance.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String teacherName, status = null, startTime, endTime;
                holder.dataBaseHelper = new DataBaseHelper(v.getContext());

                startTime = holder.etxtStart_time_Picker.getText().toString();
                endTime = holder.etxtEnd_time_Picker.getText().toString();
                teacherName = holder.txtteacher.getText().toString();
                if (holder.radioButtonPresent.isChecked()) {
                    status = holder.radioButtonPresent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(rowView.getContext(), teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();

                } else if (holder.radioButtonAbsent.isChecked()) {
                    status = holder.radioButtonAbsent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(rowView.getContext(), teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(rowView.getContext(), "Teacher Status is not Mark", Toast.LENGTH_SHORT).show();
                }
            }
        });

        holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
        holder.txtteacher.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                for (int a = 0; a < position; a++) {
                    holder.txtteacher.setText(teacher_name[position]);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                    holder.radioButtonPresent.setChecked(true);
                    holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                }
            }
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        holder.etxtStart_time_Picker.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.etxtStart_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();
                holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
            }
        });

        holder.etxtEnd_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        holder.etxtEnd_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();
            }
        });

        holder.radioButtonAbsent.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                if (holder.radioButtonAbsent.isChecked())
                {
                    holder.etxtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                } else if (holder.radioButtonPresent.isChecked()) {
                    holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                }
            }
        });

        holder.radioButtonPresent.setOnClickListener(new OnClickListener()
        {
            public void onClick(View v)
            {
                if (holder.radioButtonPresent.isChecked()) {
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                } else if (holder.radioButtonAbsent.isChecked()) {
                    holder.etxtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.etxtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                }
            }
        });

        return rowView;
    }

    public class Holder
    {
        TextView txtlt, txtteacher;
        RadioButton radioButtonPresent, radioButtonAbsent;
        EditText etxtStart_time_Picker,etxtEnd_time_Picker;
        Spinner spinner_teacher_name, spinnerDays;
        ImageButton submitAttendance;
        RadioGroup radioButton_Group_PresentAbsent;
        DataBaseHelper dataBaseHelper;
    }
}
</code>```

答:
I read a blog to get help for my problem i have got. i want to share link where from i got help from this link

and i got this reference form this link

Answer

this class is CustomAdapter and it is extends BaseAdapter

```<code>Holder holder = new Holder();
@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    if (convertView == null) {

        // TODO Auto-generated method stub

        final View rowView;
        convertView = inflater.inflate(R.layout.row_layout, null);
        holder.radioButton_Group_PresentAbsent = (RadioGroup) convertView.findViewById(R.id.radioButton_group_PresentAbsent);
        holder.radioButtonPresent = (RadioButton) convertView.findViewById(R.id.radioButton_present);
        holder.txtlt = (TextView) convertView.findViewById(R.id.text_Lt);
        holder.txtteacher = (TextView) convertView.findViewById(R.id.text_teacher_name);
        holder.radioButtonAbsent = (RadioButton) convertView.findViewById(R.id.radioButton_absent);
        holder.txtStart_time_Picker = (TextView) convertView.findViewById(R.id.txtStartTimePicker);
        holder.txtStart_time_Picker.setFocusable(false);
        holder.txtEnd_time_Picker = (TextView) convertView.findViewById(R.id.txtEndTimePicker);
        holder.txtEnd_time_Picker.setFocusable(false);
        holder.txtlt.setText(class_room[position]);
        holder.txtteacher.setText(teacher_name[position]);
        holder.submitAttendance = (ImageButton) convertView.findViewById(R.id.submit_Attendance);
        holder.submitAttendance.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name = (Spinner) convertView.findViewById(R.id.spinner_teacher_name);
        arrayAdapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, teacher_name);
        arrayAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        holder.spinner_teacher_name.setAdapter(arrayAdapter1);

        holder.submitAttendance.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                String teacherName, status = null, startTime, endTime;
                holder.dataBaseHelper = new DataBaseHelper(v.getContext());

                startTime = holder.txtStart_time_Picker.getText().toString();
                endTime = holder.txtEnd_time_Picker.getText().toString();
                teacherName = holder.txtteacher.getText().toString();
                DataBaseHelper ds = new DataBaseHelper(context);

                if (holder.radioButtonPresent.isChecked()) {
                    status = holder.radioButtonPresent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(context, teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();

                } else if (holder.radioButtonAbsent.isChecked()) {
                    status = holder.radioButtonAbsent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(context, teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(context, "Teacher Status is not Mark", Toast.LENGTH_SHORT).show();
                }
            }
        });

        holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
        holder.txtteacher.setVisibility(View.VISIBLE);

        holder.spinner_teacher_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                for (int a = 0; a < position; a++) {
                    holder.txtteacher.setText(teacher_name[position]);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                    holder.radioButtonPresent.setChecked(true);
                    holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                }
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        holder.txtStart_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.txtStart_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();

                holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
            }
        });

        holder.txtEnd_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                // TODO Auto-generated method stub
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.txtEnd_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();

            }
        });

        holder.radioButtonAbsent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.radioButtonAbsent.isChecked()) {
                    holder.txtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                } else if (holder.radioButtonPresent.isChecked()) {
                    holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                }
            }
        });
        holder.radioButtonPresent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.radioButtonPresent.isChecked()) {
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                } else if (holder.radioButtonAbsent.isChecked()) {
                    holder.txtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.txtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                }
            }
        });

        convertView.setTag(holder);
        convertView.setTag(R.id.radioButton_group_PresentAbsent, holder.radioButton_Group_PresentAbsent);
        convertView.setTag(R.id.radioButton_present, holder.radioButtonPresent);

        convertView.setTag(R.id.text_Lt, holder.txtlt);
        convertView.setTag(R.id.radioButton_present, holder.radioButtonPresent);
        convertView.setTag(R.id.text_teacher_name, holder.txtteacher);
        convertView.setTag(R.id.radioButton_absent, holder.radioButtonAbsent);
        convertView.setTag(R.id.txtStartTimePicker, holder.txtStart_time_Picker);
        convertView.setTag(R.id.txtEndTimePicker, holder.txtEnd_time_Picker);
        convertView.setTag(R.id.submit_Attendance, holder.submitAttendance);
        convertView.setTag(R.id.spinner_teacher_name, holder.spinner_teacher_name);
    }
    else
    {
        holder = (Holder) convertView.getTag();
    }
    holder.radioButtonPresent.setTag(position);
    holder.radioButtonAbsent.setTag(position);

    return convertView;
}
public class Holder
{
    protected TextView txtlt, txtteacher;
    RadioButton radioButtonPresent, radioButtonAbsent;
    TextView txtStart_time_Picker,txtEnd_time_Picker;
    Spinner spinner_teacher_name, spinnerDays;
    ImageButton submitAttendance;
    RadioGroup radioButton_Group_PresentAbsent;
    DataBaseHelper dataBaseHelper;
}
</code>```

i work very hard to get this solution finally i got now i want to share on this website cause i also got lot of solutions form this website.

Body:
when ever i move down scroll the widgets refresh . i need to stop refresh

when ever i move down scroll the widgets refresh . i need to stop refresh. the valus of widgets shuld be remain till image button clicked.
 after change values of widgets when i scroll up after down the widgets values reset . the values should be remain as i perform action.

this is refreshing widgets

XML file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="30dp"
android:textColor="#000"
>

<TextView
    android:id="@+id/text_Lt"
    android:layout_width="30dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="6dp"
    android:gravity="center"
    android:textAlignment="center"
    android:textColor="#000"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    />
<LinearLayout
    android:id="@+id/Teacher_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:orientation="vertical"
    android:textColor="#000"
    >

<TextView
    android:id="@+id/text_teacher_name"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:textColor="#000"
    android:layout_marginTop="10dp"
    />
<Spinner
    android:id="@+id/spinner_teacher_name"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:layout_marginTop="-20dp">
</Spinner>
</LinearLayout>
<LinearLayout
    android:id="@+id/radioButtons"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:orientation="vertical">

    <RadioGroup
        android:id="@+id/radioButton_group_PresentAbsent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <RadioButton
            android:id="@+id/radioButton_present"
            android:layout_width="80dp"
            android:layout_height="25dp"
            android:text="Present"
            android:textSize="12sp"
            />

        <RadioButton
            android:layout_marginTop="3dp"
            android:id="@+id/radioButton_absent"
            android:layout_width="80dp"
            android:layout_height="25dp"
            android:text="Absent"
            android:textSize="12sp"
            />
    </RadioGroup>
</LinearLayout>

<EditText
    android:id="@+id/etxtStartTimePicker"
    android:layout_width="50dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:textSize="11sp"
    android:text="LATE"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"/>
<EditText
    android:id="@+id/etxtEndTimePicker"
    android:layout_width="50dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:textSize="11sp"
    android:text="LEAVE"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    android:visibility="invisible"
    />
<ImageButton
    android:id="@+id/submit_Attendance"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="2.5dp"
    android:layout_marginBottom="2.5dp"
    android:src="@drawable/biit"
    android:visibility="visible"/>
</LinearLayout>

after change values of widgets when i scroll up after down the widgets values reset , please help . the values should be remain as i perform action.
Java File

public class CustomAdapter extends BaseAdapter
{
    private static LayoutInflater inflater = null;
    String[] class_room;
    Context context;
    String[] teacher_name;
    String[] days;
    ArrayAdapter<String> arrayAdapter1;
    Calendar c = Calendar.getInstance();

    public CustomAdapter(teacher_attendance mainActivity, String[] arr, String[] arr1, String[] arr2) {
        // TODO Auto-generated constructor stub
        class_room = arr;
        teacher_name = arr1;
        days=arr2;
        context = mainActivity;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return class_room.length
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        final Holder holder = new Holder();
        final View rowView;

        rowView = inflater.inflate(R.layout.row_layout, null);
        holder.radioButton_Group_PresentAbsent = (RadioGroup) rowView.findViewById(R.id.radioButton_group_PresentAbsent);
        holder.radioButtonPresent = (RadioButton) rowView.findViewById(R.id.radioButton_present);
        holder.txtlt = (TextView) rowView.findViewById(R.id.text_Lt);
        holder.txtteacher = (TextView) rowView.findViewById(R.id.text_teacher_name);
        holder.radioButtonAbsent = (RadioButton) rowView.findViewById(R.id.radioButton_absent);
        holder.etxtStart_time_Picker = (EditText) rowView.findViewById(R.id.etxtStartTimePicker);
        holder.etxtStart_time_Picker.setFocusable(false);
        holder.etxtEnd_time_Picker = (EditText) rowView.findViewById(R.id.etxtEndTimePicker);
        holder.etxtEnd_time_Picker.setFocusable(false);
        holder.txtlt.setText(class_room[position]);
        holder.txtteacher.setText(teacher_name[position]);
        holder.submitAttendance = (ImageButton) rowView.findViewById(R.id.submit_Attendance);
        holder.submitAttendance.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name = (Spinner) rowView.findViewById(R.id.spinner_teacher_name);
        arrayAdapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, teacher_name);
        arrayAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        holder.spinner_teacher_name.setAdapter(arrayAdapter1);
        holder.submitAttendance.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String teacherName, status = null, startTime, endTime;
                holder.dataBaseHelper = new DataBaseHelper(v.getContext());

                startTime = holder.etxtStart_time_Picker.getText().toString();
                endTime = holder.etxtEnd_time_Picker.getText().toString();
                teacherName = holder.txtteacher.getText().toString();
                if (holder.radioButtonPresent.isChecked()) {
                    status = holder.radioButtonPresent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(rowView.getContext(), teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();

                } else if (holder.radioButtonAbsent.isChecked()) {
                    status = holder.radioButtonAbsent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(rowView.getContext(), teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(rowView.getContext(), "Teacher Status is not Mark", Toast.LENGTH_SHORT).show();
                }
            }
        });

        holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
        holder.txtteacher.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                for (int a = 0; a < position; a++) {
                    holder.txtteacher.setText(teacher_name[position]);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                    holder.radioButtonPresent.setChecked(true);
                    holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                }
            }
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        holder.etxtStart_time_Picker.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.etxtStart_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();
                holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
            }
        });

        holder.etxtEnd_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        holder.etxtEnd_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();
            }
        });

        holder.radioButtonAbsent.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                if (holder.radioButtonAbsent.isChecked())
                {
                    holder.etxtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                } else if (holder.radioButtonPresent.isChecked()) {
                    holder.etxtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                }
            }
        });

        holder.radioButtonPresent.setOnClickListener(new OnClickListener()
        {
            public void onClick(View v)
            {
                if (holder.radioButtonPresent.isChecked()) {
                    holder.etxtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                } else if (holder.radioButtonAbsent.isChecked()) {
                    holder.etxtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.etxtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                }
            }
        });

        return rowView;
    }

    public class Holder
    {
        TextView txtlt, txtteacher;
        RadioButton radioButtonPresent, radioButtonAbsent;
        EditText etxtStart_time_Picker,etxtEnd_time_Picker;
        Spinner spinner_teacher_name, spinnerDays;
        ImageButton submitAttendance;
        RadioGroup radioButton_Group_PresentAbsent;
        DataBaseHelper dataBaseHelper;
    }
}

Body:
I read a blog to get help for my problem i have got. i want to share link where from i got help from this link

and i got this reference form this link

Answer

this class is CustomAdapter and it is extends BaseAdapter

Holder holder = new Holder();
@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    if (convertView == null) {

        // TODO Auto-generated method stub

        final View rowView;
        convertView = inflater.inflate(R.layout.row_layout, null);
        holder.radioButton_Group_PresentAbsent = (RadioGroup) convertView.findViewById(R.id.radioButton_group_PresentAbsent);
        holder.radioButtonPresent = (RadioButton) convertView.findViewById(R.id.radioButton_present);
        holder.txtlt = (TextView) convertView.findViewById(R.id.text_Lt);
        holder.txtteacher = (TextView) convertView.findViewById(R.id.text_teacher_name);
        holder.radioButtonAbsent = (RadioButton) convertView.findViewById(R.id.radioButton_absent);
        holder.txtStart_time_Picker = (TextView) convertView.findViewById(R.id.txtStartTimePicker);
        holder.txtStart_time_Picker.setFocusable(false);
        holder.txtEnd_time_Picker = (TextView) convertView.findViewById(R.id.txtEndTimePicker);
        holder.txtEnd_time_Picker.setFocusable(false);
        holder.txtlt.setText(class_room[position]);
        holder.txtteacher.setText(teacher_name[position]);
        holder.submitAttendance = (ImageButton) convertView.findViewById(R.id.submit_Attendance);
        holder.submitAttendance.setVisibility(View.VISIBLE);
        holder.spinner_teacher_name = (Spinner) convertView.findViewById(R.id.spinner_teacher_name);
        arrayAdapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, teacher_name);
        arrayAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        holder.spinner_teacher_name.setAdapter(arrayAdapter1);

        holder.submitAttendance.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                String teacherName, status = null, startTime, endTime;
                holder.dataBaseHelper = new DataBaseHelper(v.getContext());

                startTime = holder.txtStart_time_Picker.getText().toString();
                endTime = holder.txtEnd_time_Picker.getText().toString();
                teacherName = holder.txtteacher.getText().toString();
                DataBaseHelper ds = new DataBaseHelper(context);

                if (holder.radioButtonPresent.isChecked()) {
                    status = holder.radioButtonPresent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(context, teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();

                } else if (holder.radioButtonAbsent.isChecked()) {
                    status = holder.radioButtonAbsent.getText().toString();
                    holder.dataBaseHelper.insertData(teacherName, status, startTime, endTime);
                    Toast.makeText(context, teacher_name[position] + " is " + status, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(context, "Teacher Status is not Mark", Toast.LENGTH_SHORT).show();
                }
            }
        });

        holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
        holder.txtteacher.setVisibility(View.VISIBLE);

        holder.spinner_teacher_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                for (int a = 0; a < position; a++) {
                    holder.txtteacher.setText(teacher_name[position]);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                    holder.radioButtonPresent.setChecked(true);
                    holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                }
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        holder.txtStart_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.txtStart_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();

                holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
            }
        });

        holder.txtEnd_time_Picker.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                // TODO Auto-generated method stub
                TimePickerDialog.OnTimeSetListener tim = new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        holder.txtEnd_time_Picker.setText(hourOfDay + " : " + minute);
                    }
                };
                new TimePickerDialog(context, tim, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();

            }
        });

        holder.radioButtonAbsent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.radioButtonAbsent.isChecked()) {
                    holder.txtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                } else if (holder.radioButtonPresent.isChecked()) {
                    holder.txtEnd_time_Picker.setVisibility(View.VISIBLE);
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                }
            }
        });
        holder.radioButtonPresent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.radioButtonPresent.isChecked()) {
                    holder.txtStart_time_Picker.setVisibility(View.VISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.INVISIBLE);
                    holder.txtteacher.setVisibility(View.VISIBLE);
                } else if (holder.radioButtonAbsent.isChecked()) {
                    holder.txtStart_time_Picker.setVisibility(View.INVISIBLE);
                    holder.txtEnd_time_Picker.setVisibility(View.INVISIBLE);
                    holder.spinner_teacher_name.setVisibility(View.VISIBLE);
                    holder.txtteacher.setVisibility(View.INVISIBLE);
                }
            }
        });

        convertView.setTag(holder);
        convertView.setTag(R.id.radioButton_group_PresentAbsent, holder.radioButton_Group_PresentAbsent);
        convertView.setTag(R.id.radioButton_present, holder.radioButtonPresent);

        convertView.setTag(R.id.text_Lt, holder.txtlt);
        convertView.setTag(R.id.radioButton_present, holder.radioButtonPresent);
        convertView.setTag(R.id.text_teacher_name, holder.txtteacher);
        convertView.setTag(R.id.radioButton_absent, holder.radioButtonAbsent);
        convertView.setTag(R.id.txtStartTimePicker, holder.txtStart_time_Picker);
        convertView.setTag(R.id.txtEndTimePicker, holder.txtEnd_time_Picker);
        convertView.setTag(R.id.submit_Attendance, holder.submitAttendance);
        convertView.setTag(R.id.spinner_teacher_name, holder.spinner_teacher_name);
    }
    else
    {
        holder = (Holder) convertView.getTag();
    }
    holder.radioButtonPresent.setTag(position);
    holder.radioButtonAbsent.setTag(position);

    return convertView;
}
public class Holder
{
    protected TextView txtlt, txtteacher;
    RadioButton radioButtonPresent, radioButtonAbsent;
    TextView txtStart_time_Picker,txtEnd_time_Picker;
    Spinner spinner_teacher_name, spinnerDays;
    ImageButton submitAttendance;
    RadioGroup radioButton_Group_PresentAbsent;
    DataBaseHelper dataBaseHelper;
}

i work very hard to get this solution finally i got now i want to share on this website cause i also got lot of solutions form this website.


问:
Getting "cannot load Java class org.sikuli.script.Keys" while trying to run cucumber test using sikuli
I'm trying to set up testing environment using sikuli+jruby+cucumber.
So I've installed latest JDK, Sikulix 1.1.1 , and latest JRuby, set up the cucumber test inspired by https://github.com/fozzie63/sikuli-jruby-cucumber
and when i'm trying to run test i get the following exception:

```<code>sikulitest EugeneMarrow$ cucumber
missing class or uppercase package name (`org.sikuli.script.Keys'), caused by (NameError) cannot load Java class org.sikuli.script.Keys (NameError)
</code>```

I've tried to:
- downgrade to JDK 7 and switched back to JDK8;
- reinstall JRuby;
- use Sikulix Nightly Builds 1.1.2;

I'm running it on MacOS Sierra.

答: I would trouble shoot my classpath if I saw an error like this. To me it is clear that you are missing something or referring to it with the wrong case.</p>

Body:
I'm trying to set up testing environment using sikuli+jruby+cucumber.
So I've installed latest JDK, Sikulix 1.1.1 , and latest JRuby, set up the cucumber test inspired by https://github.com/fozzie63/sikuli-jruby-cucumber
and when i'm trying to run test i get the following exception:

sikulitest EugeneMarrow$ cucumber
missing class or uppercase package name (`org.sikuli.script.Keys'), caused by (NameError) cannot load Java class org.sikuli.script.Keys (NameError)

I've tried to:
- downgrade to JDK 7 and switched back to JDK8;
- reinstall JRuby;
- use Sikulix Nightly Builds 1.1.2;

I'm running it on MacOS Sierra.