Why Medical Care in America Is So Expensive

Medical care in America is excellent but expensive, with drug costs being no exception to the general pattern. US medical firms are leaders in innovation, but at a high price to consumers, who are increasingly aware that drug costs just over the border in Canada are considerably lower. When challenged on this, especially by the elderly, the drug companies reply that medicine costs a lot in America because it has to: “It’s all that research we do. There is nothing controversial.” No research, no new formulas, no new ingredients, no new drugs, no medical evolution in the critical struggle with high blood pressure, heart disease, liver disease, strokes, cancer and all the other common illnesses and bacteria that can make old age miserable or short.

So is it just laboratory budgets and the salaries of scientists and technicians that explain the high prices? Washington Post editorial cartoonist Tom Toles thinks not. The drug company executive opens the elevator door to the Research Division to show us some busy corporate “researchers”. What are they working on?

The first pointy-headed figure is devising the digital TV ads that are the key feature of the extremely expensive advertising campaigns these firms now use to sell drugs directly to consumers. The second is putting together a selection of “goodies for doctors”—favors and services that will induce (i.e. bribe) physicians to prescribe their drugs regardless of cost. The third figure is studying the fees that companies pay to expensive law firms to fight for extension of patent rights on drugs; patents themselves also tend to keep prices high, in theory to reward inventors for the introduction of a useful new product. Last comes the researcher who studies how much money the firm should pay to the re-election campaigns of politicians in Congress to guarantee that the laws serve the financial interests of the drug industry.

Medical research is pointedly absent. This is an exaggeration on Tole’s part, since these firms really do spend huge sums on science—but promotional and legal expenses are, as Toles insists, far from being neglected.

The Shepherd’s Daughter

It is the opinion of my grandmother that all men should labor, and at the table, a moment ago, she said to me: Necessity is the mother of invention; you must learn to do some good work, make some item useful to man, something out of clay, or out of wood, or metal, or cloth. It is not proper for a young man to be ignorant of an honorable craft. Is there anything you can make? Can you make a simple table, a chair, a plain dish, a rug, a coffee pot? Is there anything you can do?

And my grandmother looked at me with anger and took up a broom, ready to beat me. “As an old saying goes, spare the rod, spoil the child,” she said, “You are supposed to be a writer and I suppose you can make writing your occupation. You certainly smoke enough cigarettes to be anything; smoking is a vice and a hazard to your health and the whole house is full of the smoke. But you must learn to make solid things, they do not need to be very complicated, just things that can be used, that can be seen and touched, so that you can contribute to society. If you never saw, you will never reap.”

There was a king of the prosperous Persians with a powerful fleet of naval vessels, said my grandmother, and he had a son, and this son fell in love with a shepherd’s daughter, who lived in a small cottage on the coast. He went to his father and he said, “My Lord, I love a shepherd’s daughter, and I want to have her as my bride.” And the king said, “I am king and you are my son, and when I die you shall be king, how can it be that you would marry the daughter of a shepherd?” And the son said, “My Lord, I do not know but I know that I love this girl and want to have her for my queen and I’m not going to accept any compromise in this issue.”

The king saw that his son’s love for the girl was from God, and he said, “I will send a message to her.” And he called a messenger to him and he said, “Go to the shepherd’s daughter and say that my son loves her and wants to have her for his wife.” And the messenger went to the girl and he said, “The king’s son loves you and wants to have you for his wife.” And the girl said, “What labor does he do?” And the messenger said, “Why? he is the son of the king; he does no labor.” And the girl said, “He can have me provided that he must learn to do some labor, for instance, like a carpenter or butcher.” And the messenger returned to the king’s castle and spoke the words of the shepherd’s daughter.

The king said to his son, “The shepherd’s daughter wishes you to learn some craft. Would you still have her for your wife?” And the son said, “Absolutely, I will learn to weave straw rugs.” And the boy was taught to weave rugs of straw, in patterns and in colors and with ornamental designs, and at the end of three days he was making very fine straw rugs, and the messenger returned to the shepherd’s daughter, and he said, “There rugs of straw are the work of the king’s son.” And the girl went with the messenger to the king’s palace, and she became the wife of the king’s son.

One day, said my grandmother, the king’s son was walking through the downtown streets of Baghdad, and he came upon and eating-place which was so clean and cool that he entered it and sat at a table for some dessert.

This place, said my grandmother, was a place of thieves and murderers, and they took the king’s son and placed him in a large jail where many great men of the city were being held, and the thieves and murderers were executing the fattest of the men with and axe and feeding them to the leanest of them, and making sport of it. The king’s son was of the leanest of the men, and it was not known that he was the son of the king of the Persians, so his life was spared, and he said to the thieves and murderers, “I am a waver of straw rugs and I swear to God that these rugs have great value.” And they brought him straw and asked him to weave and in three days he superb rugs, and he said, “Garry these to the palace of the king of the Persians, and for each rug he will give you a hundred gold pieces of money.” And the rugs were carried to the palace of the king, and when the king saw the rigs he saw that they were the work of his son and he took the rugs to the shepherd’s daughter and he said, “These rugs were brought to the palace and they are the work of my son who is lost.” And the shepherd’s daughter took each rug and looked at it closely and in the design of each rug she saw in the written language of the Persians a message from her husband, and she related this message to the king.

And the king, said my grandmother, sent many soldiers to conduct a swift raid on the location of the gang of criminals, and the soldiers rescued all the prisoners and arrested all the thieves and murderers, who were subsequently accused and convicted of horrible crimes in court trials, and the king’s son returned safely to the palace of his father, and to the company of his wife, the little shepherd’s daughter. And after the boy regained his freedom, he went into the palace and saw again his wife, he humbled himself before her and he embraced her feet, and he said, “My love, it is because of you that I am alive.” And the king was exceedingly pleased with the shepherd’s daughter.

“Now,” said my grandmother, “do you see why every man should learn an honorable craft?”

“I see very clearly,” I said, “and as soon as I earn enough money to buy a handy saw, a hammer and some nails and a piece of timber I shall do my best to make a simple chair or shelf for books or some other stuff.”

Time for a Bath

I haven’t taken a bath in years. No, it’s not a lack of good personal habits; it’s that I’m a shower man. To me, a bath seems like a luxury, a waste of time and water. Drawing near the bath, carefully lowering myself in, feeling around for the soap like a big fish after some smaller sea creature, then washing myself in slow motion, as one tends to do underwater—it all seems very leisurely. Then, too, I don’t know how to wash my hair in the bathtub. But my main problem is that it feels… delightful. It’s like a trip back to your mother’s body, and I’m tempted to stay a bit longer and enjoy it—not good if I have to be somewhere in an hour.

Baths are for kids, I think, rightly or wrongly. My 11-year-old son insists on taking a bath before he goes to bed every night—no nagging required. I think he is the cleanest 11-year-old in town, but the appeal for him isn’t about getting clean. The warm water seems to relax him, to calm his confusion of thoughts. Often, I sit on the floor by the bathtub while he’s in there and we talk about things: Harry Potter, space aliens, why his fifth-grade classmates insist that anyone using chapstick is applying lipstick. You know—the burning issues of our day. After a few minutes of soaking and unwinding these conversational threads, he’s ready to sleep as soon as his head hits the pillow (well, most of the time).

My wife likes a leisurely bath, too. For her, it’s good for the health, especially when accompanied by mountains of bubbles, various bath oils and salts and, occasionally, candles. I could not take such a bath with a straight face, but I admire those who can.

I do like to sit in a hot tub, whenever I stay in a hotel or motel that has one—which is perhaps once a year, while on vacation. But such a soak is a special occasion. It doesn’t elicit any feelings of guilt, unless I stay in longer than, say, 20 minutes. But by then I’m ready to get out anyway, since I’m starting to feel like a boiled crab.

Maybe I’ll take a bath sometime soon, just to reconnect with my fetal self and relax a little. As soon as I have an hour in the morning or evening to spare, I’ll do it. And when will that be, he asks himself.

Butterfiles

There was a time in my life when beauty meant something special to me. I guess that would have been when I was about six or seven years old in the orphanage.

I would get up every morning, make my bed and get into one of the two straight lines and march to breakfast with the other boys who also lived in my dormitory.

After breakfast one Saturday morning I returned to the dormitory and saw the house parent chasing the beautiful butterflies who lived by the hundreds in the bushes around the orphanage.

I carefully watched as he caught these beautiful creatures, one after the other, and then took them from the net and then stuck straight pins through their head and wings, pinning them onto a heavy cardboard sheet.

How cruel it was to kill something of such beauty. I had walked many times out into the bushes, all by myself, just so the butterflies could land on my head, face and hands so I could look at them up close.

When the telephone rang the house parent laid the large cardboard paper down on the back cement step and went inside to answer the phone. I walked up to the cardboard and looked at one of the butterflies that he had just pinned to the large paper. It was still moving about, so I reached down and touched it on the wing causing one of the pins to fall out. It started flying around and around trying to get away but it was still pinned by the other wing with another straight pin. Finally its wing broke off and the butterfly fell to the ground and just quivered.

I picked up the torn wing and the butterfly and I spat on it’s wing and tried to get it to stick back on so it could fly away and be free before the house parent came back. But it would not stay on him.

The next thing I knew was the house parent came walking back out of the back door by the garbage room and started yelling at me. I told him that I did not do anything but he did not believe me. He picked up the cardboard paper and started hitting me on the top of the head by. There were all kinds of butterfly pieces going everywhere. He threw the cardboard down on the ground and told me to pick it up and put it in the garbage can inside the back room of the dormitory and then he left.

I sat there in the dirt, by that peach tree, for the longest time trying to fit all the butterfly pieces back together so I could bury them whole, but it was too hard to do. So I prayed for them and then I put them in an old torn up shoebox and I buried them in the bottom of the fort that I had built in the ground.

Every year when the butterflies would return to the orphanage and try to land on me I would try and chase them away, because they did not know that the orphanage was a bad place to live and a very bad place to die.

Shorty

This is about a little puppy dog. Her name was Shorty. She was the cutest little thing, though she used to be called Short Rat, and other things. She was the perfect addition to my family a long time ago.

I think I was in middle school at the time, my mom and dad did paper routes to earn extra money for the home. One very cold and snowy day while we were all helping with the routes to get them done quicker Dad came up to us with his paper bag held in front of him. What was inside became a wonderful addition. You see, Shorty was left to freeze and fend for herself, but lucky enough for her my dad found her near a barn.

She would go and run around our yard when we lived in town, and with us when we moved to my Grandma’s house that my mom inherited. Shorty was never scared of anything. I had seen Shorty walk up to large aggressive German Shepherds and try to scare them off. This dog was an interesting sort, she would go after deer, but always got chased by the deer instead.

She was our watch dog. One night, while my parents were watching an opera on cable TV and I was playing chess with my cousin, she suddenly barked. It turned out that a thief who had previously been arrested for and convicted of drug abuse, was trying to sneak into our house to steal our antique brass clock in the bedroom. Shorty’s barking alerted us and scared the thief, who then slipped and fell down into the ditch, breaking one rib and getting a lump on his head. With Shorty, we didn’t have to install any alarm in our house.

She was around for some of the biggest events in my life. When my grandpa died, she was there; when my grandma died, she was there; when I had two friends commit suicide at different times, she was there. She was at my graduation party, I got pictures of her when I was dressed up for a class dance. She attacked me with lots of puppy kisses when I returned home from Spain, and Las Vegas, and Tennesse.

Throughout all of the good or bad times in my life for the longest time she was there. Sometimes I may have said I didn’t like her, but she was a constant reminder that I was always loved. I miss her a great deal.

When the end started coming I finally realized how old she was, we had had her for 13years, but she was already full grown when we got her. So I don’t know how old she really was. But for those 13 years of my life she was something I could count on. She started getting white fur from age. She couldn’t move around as well, nor jump on my mom’s bed without help anymore. I would do anything for that puppy when I was at my mom’s house. I would help her outside, and back inside, take food into my mom’s room for her, and kept my daughter from pulling her ears, though she seemed to love having my little lady there with her.

I think the thing I am most grateful for, is the fact that Shorty gave so much love, and that I could see that she had love in abundance in return, from my family, my sisters family, from friends I grew up with, but most of all my mom. Shorty was my mom’s puppy, always was and always will be.

Shorty was loved, and that’s what matters.

The Affair

Out of the blue, after 25 wonderful years of being married to the sweetest girl in the world, my wife walked up to me and asked me, “have you ever cheated?”

I was speechless. A thousand thoughts raced through my mind. How could she have known? Did someone tell her? Who told her? How long had she known?

I was sure she noticed the sudden change in my behavior. I felt like I’d been run over by a lorry. Immediately, I was overcome with guilt and was so ashamed. Should I lie to her? Should I tell her the truth? I could have confessed long ago, but I did not want to hurt her.

I panicked. My bottom lip began to quiver and tremble as I tried to speak.

She began crying. She turned my face to hers, looking me in the eye, and between sobs, she asked once again, “have you ever cheated?”

She was tearing me a part… I thought my heart would surely break… She knew… She had to…

The memories that I had held back for so long came flooding back into my mind. I remembered every little indecent detail. Oh, the horror of it all. I don’t know why I did it. I surely didn’t think anyone would find out… It started in the 1st grade and I cheated all through school. I had cheated for 12 years, but why would someone tell my wife? I could not lie to her, the mother of my children, the daughter of my father-in-law… I finally looked her in the eye and said calmly but firmly, “Yes darling, I cheated… I did it… For 12 years I cheated!”

She tried to pull away, then finally broke free. She ran from the room, crying hysterically, as she ordered me from our home. “You will never see the children again! I want a divorce right away!” she screamed at me…

I could not believe that my cheating had hurt her this much. They were just spelling tests and maybe a couple of history quizzes, for crying out loud… I tried to hug her, to explain why I had cheated…

On the spur of the moment, she slapped me repeatedly, calling me unprintable names… She finally resorted to violence. She punched and kicked me. I guess I deserved it as a penalty… I covered my head, trying to ward off any serious, damaging blows from her fists. It was beginning to make me mad… I screamed at her, “haven’t you ever cheated? Well have you?”

My wife turned to me and boastfully, proudly replied, “well I wasn’t going to tell you, but since I know what a total loser you are now, I guess it doesn’t matter anymore. Yes, I have cheated… With Fred, Danny, Bill, Bobby, John and Tommy! And what you can do me?”

Love

It was my fifty-fifth birthday today. Looking at the man laying lazily on the big, soft sofa, every hope of getting a decent present this year died away. I could never expect any surprise from this unromantic man who worked as a dentist in a clinic on the largest avenue of the city.

Busying myself with the household chores, before long, nightfall arrived. I knew that my husband would prepare the same tedious celebration for me, the same old fried duck would be staring at me from the table dressed up in black sauce, as usual, no surprises. This had become a yearly routine fro him. Trying to forget the hurt, I further drilled myself in the piles of office administration work, finding “comforts” in them while waiting for his call to the celebration.

Amazingly, his yearly eleven o’clock call did not reach my ears this time. Although feeling curious, I made no attempts to find out.

Suddenly, my world turned pitch dark halfway through my work. A familiar pair of enormous rough-skinned hands over my eyes. I was bewildered at the thought of my husband trying to be romantic.

Without a word, he led me out of my tiring, boring world into the warm, loving arm of his. He whispered instructions into my ears wanting me to feel the present he bought for me to celebrate my birthday.

Feelings of excitement, love and happiness rose up form the very core of my heart. Eagerly I lowered my hands into the box. My first touch with the cold solid sent a thrilling shock to my whole body, charging me with a new form of unexplainable energy. With my further anxious explorations, I came to find out that the mysterious gift turned out to take the form of a round object with a tiny little precise cut of an object sticking out of it.

My heart screamed with joy when I ran my fingers across this delicate object. Somehow or other, I knew that it was going to be a diamond ring. Finally, he acknowledged my desire. I had been hinting to him for the past thirty years, but each time he conveniently ignored my cues. By giving me this ring, he was trying to prove that he actually appreciated me and my efforts of bringing up his two sons.

I could not wait to show him my gratitude for his generosity.

At last, his hands deliberately inched away from my eyes. Slowly I opened my eyes, anticipating the look of my diamond ring.

My eyes flared opened to the size of saucers, when I saw a duplicate of the lost button to my favorite dress.

A Step to Romance

Peter could no longer remain indoors, not another minute. “Damn it!” He cursed the tremendous pressure at work as the deadline for a major assignment approached and files were piling on his desk. In frustration, he accidentally hit a key on the keyboard and deleted part of the draft of a sales chart he was working on. The data on his computer screen looked like a total mess. However, the beautiful spring day outside gave him some vague strange feelings. It left him helpless with no control over himself. He undid the first two buttons on his shirt, grabbed a piece of tissue paper to wipe the sweat off his forehead, and walked out of his office. Peter kept going until he reached Highland Amusement park. He knew this park here he had felt the first excitement of love more than 25 years ago. Now he was a married man with a wife and 12 year’s old boy and he loved them dearly, but it was spring and somehow he felt free as the wind, the way he felt in his twenties when he thought he had the world in his hands.

The park which was dotted by colorful banners and flags was overwhelmed by a holiday atmosphere as if life had opened a new road for the people. He felt the same way deep down within himself. He wanted something to happen to him, something new and different. He thought of his wife knitting her sweater. Billy would be playing his guitar or fixing his bicycle. If he had been at home with them, he would be fixing the leaking filter in the kitchen and working around the house. But he did not feel like that now. The fever of adventure rose within him. He was carried away by rebellion against the principle he had respected.

Inside the amusement park, he stopped in front of a shooting gallery and watched a man shoot down ten white ducks and pigeons. The gallery owner turned to Peter and said, “Come on. Try your luck; for a few pennies, you have the chance to win a nice prize fro your girlfriend.” Peter laughed. “OK, Brother,” he said, “I will try it.” Previously a boy scout and now an amateur shooter in his leisure time, Peter happily picked up a rifle, aimed at the moving ducks and pulled the trigger quickly; shot after shot flew out of the barrel in quick successions, all hitting the target. There was a big applause from the gay crowd of onlookers and he won a big doll!

He walked away in triumph and scanned the park, and then he saw a strikingly beautiful young woman in a blouse and jeans carrying a handbag. She walked gracefully and her hips were swaying slightly. Without hesitation, Peter held the doll out to her and said, “Pardon me, but would you do me a favor? I feel funny carrying this doll around. So would you mind taking it? It needs a mother.” The girl shook off her surprise and laughed. “Well. If it embarrasses you, I suppose there is nothing else I can do.” She accepted the doll and thanked him. “It’s lovely. Where ever did you get it?” “I won it at the shooting gallery,” he told her and almost without realizing it, he was walking beside her up the path through the park.

They began to talk about different things. The girl told him her name was Louise and she worked for a film studio and enjoyed collecting postage stamps in her leisure time. She thought he was about 33, more than 12 years younger than he really was, and this delighted Peter. Now chatting, laughing with this dark haired, blue eyed girl, he seemed to go back again through the years to those days when he was young and free. He knew clearly he could not possibly mean anything to her and he could not forget he was a family man with responsibilities and a son who loved him and looked up to him. And yet it was strange that he couldn’t stop now. “Let’s go to the Ferris wheel. Do you like that?” Peter asked her. Louise’s face lit up and Peter noticed how eager her eyes were.

She sat close to him and the great wheel turned and sent them skyward. He felt her finger holding his own and a warm flood rose within him. Peter felt as if he was floating on a cloud. The world seemed so much more alive, almost new again. After the Ferris whee, they tried a small motorboat, and after that they had ice-cream and chocolate in a nearby pub. Peter discovered that he was still a good dancer as ever and they entered a dance hall. While dancing he forgot everything, his wife, his child and everything.

He was 21 again. This blue-eyed girl at his side, this lovely stranger who leaned against him, clung to him with her hand on his lap, was his sweetheart. Louise said, “I wonder why, but I do enjoy being with you so much. Somehow you seem different. Where do you live? I have never seen you before. I’d like to… well, what I mean is, don’t you think we two get along quite nicely?” “You are perfectly right, Louise, shall we dance some more?” “Peter,” she spoke his name as if she were truly his girlfriend, as if she had taken him for her own, “Peter, don’t you believe that we should see each other again?” She leaned closer. Soon Peter was uncertain of himself.

Sooner or later he knew it would come to this. He tried to retain his calmness. Finally he said, “That is easy. Let me have your telephone number and I’ll give you a call.” When the sun was setting and thunder was heard on the horizon, Peter took her home in his car in spite of her insistence in catching a cab. At the doorstep of her house, though she probably expected him to, he made no attempt to kiss her. He didn’t even ask her to let him into her house.

The next day Peter was back at his desk, but his mind was not on his work. He kept thinking of the blue-eyed girl. He had her telephone number in his notebook. The encounter in the park doesn’t need to remain just a memory. It could be made really alive again. It was just a matter of a phone call and there would be other days even more interesting, more exciting, more fascinating, fuller in meaning. However, he was after all a married man. He did love his wife, who made a lot of personal sacrifice fro rearing their son. If anything happened that hurt his marriage he knew he would never forgive himself. That was the one thing that really meant everything to him. He thought of having an affair with the girl and promptly dismissed the idea as unworthy. He rose from his chair, waled to the open window and looked out upon the April world.

He suddenly got a strange feeling at that moment. He could hear the sweet voice of Louise in the spring breeze, he could see the lovely smile of Louise among the flowers. He got a kind of strange sickness inside. She would be waiting, expecting his phone call. He could even picture her impatience. She had told him so clearly that they must see each other again, because they were meant for each other. He returned to the desk without knowing what to do.

He slowly took out the little notebook, and put it on the desk. He picked up the phone. He started to dial her number, stopped for a moment, then went ahead and completed the dialing. A voice answered. He recognized it at once. It was Louise of course. He listened quietly. Outwardly, he tried to remain calm; but inwardly, he felt the pain, a terrible pain. He almost broke down. He hang up the phone. He took a deep breath, then picked up the phone again. This time he spoke, “Is that you Billy? Home from school already? Tell your mother I’ll be home earlier for supper. We are going to plant those new roses you and your mother love, OK?”

An Anorectic Girl

There was once a little girl who was an elementary school student. She hated everything she was offered to eat. She hated turkey, she complained it was too dry. She hated corn, she said it needed too much chewing, and the pieces stuck between her teeth and cause them to decay. She hated potatoes, they were too soft. She hated peas, they rolled right off her fork. Moreover, she hated beef, hated dairy products, hated hot dogs, hated chicken and hated fish. She hated all the major food groups, and even hated some of the minor ones, saying they were hard to digest!

She hated pizza, she said it was too cold. She hated soup, that was always too hot. She hated biscuits, they were too hard, and hated pudding, that was too soft. She hated potato chips, she said they were too loud when she bit down on them. And she also hated ice-cream, that was too cold and hurt her teeth!

Well, as she didn’t get sufficient protein in her food, the little girl got skinnier and skinnier. She hardly ate anything! The days went by and she wouldn’t mend her wasys, Finally, in desperation, one day her mom told her she couldn’t eat anything. Not the steaming piles of scrambled eggs and delicious, crispy bacon and ham for breakfast. Not the turkey sandwiches, piled hight with tomatoes, and cheese for lunch. Not the chicken, pork and crushed potatoes her mother made for dinner, Not the noodles with peppers, garlic and sausages spread on them. Her mom wouldn’t let her eat any of it. She got skinnier and skinnier, and the very next day it was Thanksgiving!

The next morning the little girl got up and watched her mom and family get ready for Thanksgiving dinner. By that afternoon the table was all set. There was a beautiful turkey, all golden brown and ready to be eaten. There were bowls and bowls of vegetables, potatoes, onions and carrots and peas and cabbages. There were three kinds of salads, and flour rolls and butter, and homemade, delicious smelling apple pies and pumpkin pies, with ice-cream to put on top.

But her mother wouldn’t let her have one bite. The little girl was confined to her room until all the rest of the family were finished. They all ate their huge Thanksgiving dinner, and all the dishes were finally washed up and everything was put away, and everyone went to sleep, all full of delicious food and wonderful memories.

When the house was all still and quiet, and everybody was in bed, the little girl licked her lips and crept slowly down the staircase. She quietly took the remaining turkey out of its wrapping, and piled a big plate high with the remaining potatoes, turkey, and vegetables. She took three heaping scoops of two different salads, and three or four rolls and butter.

She sat down and hungrily ate every single bite. Then she helped herself to the remaining pumpkin pie, since the apple pie was long gone. She ate every bite until she was completely full. Then she quietly cleaned everything up, put everything away, went to bed, and never ever complained about her food again.

Android 代码里动态设置文字颜色Seletor

今天遇到个很蛋疼的问题,下载时,多个按钮共用一个button,也就是不同下载状态下,button的背景以及字体颜色都不一样,结果自己挖了坑把自己埋进去了。
以下是我在/res/color文件夹里给button设置的文字颜色seletor:networkdata_btn_open_txtcolor_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:color="#ffffff" android:state_pressed="true"></item>
    <item android:color="#ffffff" android:state_selected="true"></item>
    <item android:color="#f88b00"></item>

</selector>

坑?
在代码里设置颜色seletor,以为在代码里直接调用 button.setTextColor(int colorValue) 就可以了,结果运行效果让我傻眼了。

怎么挖坑的?

//设置button文字
mBtnDownAndOpen.setText(DOWNLOAD_OPEN);

//设置button文字颜色
mBtnDownAndOpen.setTextColor(mContext.getResources().getColor(R.color.networkdata_btn_open_txtcolor_selector));    
//设置button背景mBtnDownAndOpen.setBackground(mContext.getResources().getDrawable(R.drawable.networkdata_btn_open_selector));    

郁闷的是,只能读取到没获取焦点时的色值,也就是 ,其他状态获取不到。

如何填坑?
采用
mBtnDownAndOpen.setTextColor(mContext.getResources().getColorStateList(R.color.networkdata_btn_open_txtcolor_selector)); 为button设置文字颜色。
区别在于:改之前用的是getColor,改之后用的是getColorStateList

WHY?
文字颜色的seletor在代码里的显示形式是ColorStateList,而res/color放的就是ColorStateList资源XML文件,getColor只能读取单个的color。

android button background图片被拉伸

button background图片被拉伸
问题:

结果是,button的背景图片被拉伸!
起因是:其他团队改变了整个应用的主题样式

解决方法:
方法一:
把layout_width和layout_height设置为固定值。如:

方法二:把Button改为ImageButton或者ImageView.

方法三:在Button的属性里增加android:minHeight=”0dp”和android:minWidth=”0dp”。如:
<Button

            android:id="@+id/recitebrowse_left"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_centerVertical="true"

            android:layout_marginLeft="@dimen/activity_head_title_margin_left"

            android:background="@drawable/newwordrecitebrowse_left_background"

            android:minHeight="0dp"

            android:minWidth="0dp"

            android:onClick="onClick" >

        </Button>

个人建议采用方法三!

NestedScrollingParent和NestedScrollingChild

public interface NestedScrollingChild {
    // 参数enabled:true表示view使用嵌套滚动,false表示禁用.
    public void setNestedScrollingEnabled(boolean enabled);

    public boolean isNestedScrollingEnabled();

    // 参数axes:表示滚动的方向如:ViewCompat.SCROLL_AXIS_VERTICAL(垂直方向滚动)和
    // ViewCompat.SCROLL_AXIS_HORIZONTAL(水平方向滚动)
    // 返回值:true表示本次滚动支持嵌套滚动,false不支持
    public boolean startNestedScroll(int axes);

    public void stopNestedScroll();

    public boolean hasNestedScrollingParent();

    // 参数dxConsumed: 表示view消费了x方向的距离长度
    // 参数dyConsumed: 表示view消费了y方向的距离长度
    // 参数dxUnconsumed: 表示滚动产生的x滚动距离还剩下多少没有消费
    // 参数dyUnconsumed: 表示滚动产生的y滚动距离还剩下多少没有消费
    // 参数offsetInWindow: 表示剩下的距离dxUnconsumed和dyUnconsumed使得view在父布局中的位置偏移了多少
    public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed,
            int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow);

    // 参数dx: 表示view本次x方向的滚动的总距离长度
    // 参数dy: 表示view本次y方向的滚动的总距离长度
    // 参数consumed: 表示父布局消费的距离,consumed[0]表示x方向,consumed[1]表示y方向
    // 参数offsetInWindow: 表示剩下的距离dxUnconsumed和dyUnconsumed使得view在父布局中的位置偏移了多少
    public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow);

    // 这个是滑动的就不详细分析了
    public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed);

    public boolean dispatchNestedPreFling(float velocityX, float velocityY);
}

  • setNestedScrollingEnabled 实现该结构的View要调用setNestedScrollingEnabled(true)才可以使用嵌套滚动.

  • isNestedScrollingEnabled判断当前view能否使用嵌套滚动.

  • startNestedScroll和stopNestedScroll.是配对使用的.startNestedScroll表示view开始滚动了,一般是在ACTION_DOWN中调用,如果返回true则表示父布局支持嵌套滚动.在事件结束比如ACTION_UP或者ACTION_CANCLE中调用stopNestedScroll,告诉父布局滚动结束.

  • dispatchNestedScroll,把view消费滚动距离之后,把剩下的滑动距离再次传给父布局.

  • dispatchNestedPreScroll,在view消费滚动距离之前把总得滑动距离传给父布局.

  • dispatchNestedFling和dispatchNestedPreFling就是view传递滑动的信息给父布局的.

public interface NestedScrollingParent {
    /**
     * 有嵌套滑动到来了,问下该父View是否接受嵌套滑动
     * @param child 嵌套滑动对应的父类的子类(因为嵌套滑动对于的父View不一定是一级就能找到的,可能挑了两级父View的父View,child的辈分>=target)
     * @param target 具体嵌套滑动的那个子类
     * @param nestedScrollAxes 支持嵌套滚动轴。水平方向,垂直方向,或者不指定
     * @return 是否接受该嵌套滑动
     */
    public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes);

    /**
     * 该父View接受了嵌套滑动的请求该函数调用。onStartNestedScroll返回true该函数会被调用。
     * 参数和onStartNestedScroll一样
     */
    public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes);

    /**
     * 停止嵌套滑动
     * @param target 具体嵌套滑动的那个子类
     */
    public void onStopNestedScroll(View target);

    /**
     * 嵌套滑动的子View在滑动之后报告过来的滑动情况
     *
     * @param target 具体嵌套滑动的那个子类
     * @param dxConsumed 水平方向嵌套滑动的子View滑动的距离(消耗的距离)
     * @param dyConsumed 垂直方向嵌套滑动的子View滑动的距离(消耗的距离)
     * @param dxUnconsumed 水平方向嵌套滑动的子View未滑动的距离(未消耗的距离)
     * @param dyUnconsumed 垂直方向嵌套滑动的子View未滑动的距离(未消耗的距离)
     */
    public void onNestedScroll(View target, int dxConsumed, int dyConsumed,
                               int dxUnconsumed, int dyUnconsumed);

    /**
     * 在嵌套滑动的子View未滑动之前告诉过来的准备滑动的情况
     * @param target 具体嵌套滑动的那个子类
     * @param dx 水平方向嵌套滑动的子View想要变化的距离
     * @param dy 垂直方向嵌套滑动的子View想要变化的距离
     * @param consumed 这个参数要我们在实现这个函数的时候指定,回头告诉子View当前父View消耗的距离 
     *                    consumed[0] 水平消耗的距离,consumed[1] 垂直消耗的距离 好让子view做出相应的调整
     */
    public void onNestedPreScroll(View target, int dx, int dy, int[] consumed);

    /**
     * 嵌套滑动的子View在fling之后报告过来的fling情况
     * @param target 具体嵌套滑动的那个子类
     * @param velocityX 水平方向速度
     * @param velocityY 垂直方向速度
     * @param consumed 子view是否fling了
     * @return true 父View是否消耗了fling
     */
    public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed);

    /**
     * 在嵌套滑动的子View未fling之前告诉过来的准备fling的情况
     * @param target 具体嵌套滑动的那个子类
     * @param velocityX 水平方向速度
     * @param velocityY 垂直方向速度
     * @return true 父View是否消耗了fling
     */
    public boolean onNestedPreFling(View target, float velocityX, float velocityY);

    /**
     * 获取嵌套滑动的轴
     * @see ViewCompat#SCROLL_AXIS_HORIZONTAL 垂直
     * @see ViewCompat#SCROLL_AXIS_VERTICAL 水平
     * @see ViewCompat#SCROLL_AXIS_NONE 都支持
     */
    public int getNestedScrollAxes();
}
  • onStartNestedScroll.当子view的调用NestedScrollingChild的方法startNestedScroll时,会调用该方法.

  • onNestedScrollAccepted.如果onStartNestedScroll方法返回的是true的话,那么紧接着就会调用该方法.它是让嵌套滚动在开始滚动之前,让布局容器(viewGroup)或者它的父类执行一些配置的初始化的.下面是原文:
    (It offers an opportunity for the view and its superclasses to perform initial configuration for the nested scroll.)

  • onStopNestedScroll停止滚动了,当子view调用stopNestedScroll时会调用该方法.

  • onNestedScroll,当子view调用dispatchNestedScroll方法时,会调用该方法.

  • onNestedPreScroll,当子view调用dispatchNestedPreScroll方法是,会调用该方法.

  • dispatchNestedFling和dispatchNestedPreFling对应的就是滑动了.

备注

Delegate 委派,代表

clamped 夹紧的

int clampedPosition = Math.max(0, Math.min(getCount() - 1, position));

invalid 无效的 有病的;残废的

防止Android过快点击造成多次事件的几种方法

方法一:

 btnPay.setClickable(false);
  或
  btnPay.setEnabled(false);

但是如果跳转页面失败呢(这里会涉及到网络请求),又要将按钮设置为true,太麻烦了(一个大型项目有多少个按钮,这得多增加多少行代码,我们的工资又不是按照行来结算的)

方法二:

public abstract class NoDoubleClickListener implements View.OnClickListener {
    public static final int MIN_CLICK_DELAY_TIME = 1000;
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }
    }

    protected abstract void onNoDoubleClick(View v);

}

///////////////////////////////////
btnPay.setOnClickListener(new NoDoubleClickListener() {
          @Override
          protected void onNoDoubleClick(View v) {
              startPay();
          }
      });

    }
public class NoDoubleClick {
    public static final int INTERVALS_TIME_300 = 300;

    private long lastClickTime = 0;
    private int intervalsTime = INTERVALS_TIME_300;


    public NoDoubleClick(int intervalsTime) {
        this.intervalsTime = intervalsTime;
    }

    public boolean isDoubleClick() {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > 0 && currentTime - lastClickTime < intervalsTime) {
            return true;
        } else {
            lastClickTime = currentTime;
            return false;
        }
    }

}
///////////////////////////////////
btnPay.setOnClickListener(new OnClickListener() {
          @Override
          protected void onClick(View v) {
              if(noDoubleClick.isDoubleClick()) return;
              startPay();
          }
      });

    }

方法三:

RxView.clicks(btnPay)
                .throttleFirst(1, TimeUnit.SECONDS)
                .subscribe(new Observer<Object>() {
                    @Override
                    public void onCompleted() {
                       //
                    }

                    @Override
                    public void onError(Throwable e) {
                        //
                    }

                    @Override
                    public void onNext(Object o) {
                        //
                    }
                });

NoLeakHandler各种版本

Leak:泄漏

public class NoLeakHandler extends Handler {
    private WeakReference<HandlerCallback> mCallback = new WeakReference<HandlerCallback>(null);
    private boolean isValid = true;

    public NoLeakHandler(HandlerCallback callback) {
        mCallback = new WeakReference<NoLeakHandler.HandlerCallback>(callback);
    }

    @Override
    public void handleMessage(Message msg) {
        if (mCallback.get() != null && isValid) {
            mCallback.get().handleMessage(msg);
        }
    }

    public interface HandlerCallback {
        public void handleMessage(Message msg);
    }

    public void setValid(boolean isValid) {
        this.isValid = isValid;
    }
}
public abstract class NoLeakHandler<T> extends Handler {  
    private WeakReference<T> mT;  

    public NoLeakHandler(T outClass) {  
        mT = new WeakReference<>(outClass);  
    }  

    @Override  
    public void handleMessage(Message msg) {  
        T t = mT.get();  
        handleMessage(msg, t);  
    }  

    public abstract void handleMessage(Message msg, T t);  
}

Git 命令

git status 查看本地状态

git stash
git stash pop

git add . // 所有文件
git add + 文件

git commit -m “xxx” 提交

git checkout + 分支 // 切换分支
git checkout + 文件 // 还原文件

git pull // 拉取最新代码
git push // 推送提交到远程

git log 查看本地日志
git log orgin/分支 查看远程分支日志

git show + xxx
git diff .
git diff + 文件

git branch -a // 查看所有分支
git branch // 查看当前分支

Android Studio Windows上常用快捷键

Ctrl+Y 删除行 delete line
Ctrl+N 搜索类
Ctrl+Alt+L 格式化
Alt+? 提示
Alt+Enter 导包

Search Everywhere Double Shift
Project View alt+1
go to file ctrl+shift+N
recent files ctrl+E
navigation bar alt+home
drop files here to open

Ctrl+Shift+U 大小写切换
Shift+Shift 全局搜索
End 行尾 move caret to line end
Shift+End move caret to line end with selection
Home
Shift+Home

Ctrl+G 跳转 go to line

Android Studio Mac上常用快捷键