text

android – How to use different style/color for text and image in pressed ListItem


Am working on a Android SDK 17+ app. A ListView uses a BaseAdapter instance to manage its items. Each item is a simple layout which only includes a TextView. The TextView uses its CompoundDrawable to show an icon.

How can I both change the text and icon/drawable color when an item is pressed/highlighted?

Activity

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    listView= (ListView)findViewById(R.id.listView);
    listView.setAdapter(new MyListAdapter(this));
    ...
}

private static class MyListAdapterextends BaseAdapter {
    ...

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.listitem__textItem, null);

            viewHolder = new ViewHolder();
            viewHolder.textView = (TextView)convertView.findViewById(R.id.textView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder)convertView.getTag();
        }

        ...
}

static class ViewHolder {
    TextView textView;
}

listitem__textItem.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout ...>
    ...
    <TextView
        ...
        android:background="@drawable/itemselector_bg" 
        android:textColor="@drawable/itemselector_text"
        android:drawableTop="@drawable/someIcon"
        ... />
</RelativeLayout>

itemselector_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@color/blue" />
    <item android:drawable="@color/white" />
</selector>

itemselector_text.xml

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:color="@color/white" />
    <item android:state_focused="true" android:color="@color/white" />
    <item android:color="@color/red" />
</selector>

Problem 1:
While changing the background by using @drawable/itemselector_bg works without a problem, using @drawable/itemselector_text to change the text color does not work.

Problem 2:
How can I change the icon color when pressed/focused?



لینک منبع

css – Text Center inside box HELP beginner


I got a problem im trading to figure our for hours now and im going crazy.

I want the text next to the icon be in the middle of the box. But I cant figure out what i have done wrong, could you also critique my code Im learning.

my CSS

#newaltcoins .boximg {
    background-color: #cccccc;
    width: 50px;
    height: 50px;

}

#newaltcoins .box{
    float:left;
    border:#cccccc solid 1px;
    color: black;
    width: 200px;
    height: 50px;
    margin: 5px;
    background-color: #EEEEEE;
    white-space:nowrap;
    text-align: center;

My html

        <a href="http://google.com">
            <div class="box">  
                    <div class="boximg" >
                           <img src="http://stackoverflow.com/./alt/alt_logo/etherieum.png">
                               <br>Etherieum
                    </div>    
            </div>
        </a>

example



لینک منبع

c# – Issue outputting text to textBox (WinForms)


It’s my first time using winforms. I’m having some issues.

   public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "FORM1";
            textBox1.AppendText("SOME TEXT");
        }
    }

I’ve tried this. My textbox is set to fill so it fills up the whole form. I set the multi-line propery to true and dock property to fill.

From what I can try as a first time WinForms user, the Form1_Load should run as soon as the form is created. I’ve tried some various ways to print text, nothing works. I noticed visual studios says “0 references” next to my function. I’m not sure what this means, maybe part of my issue? Please help.

enter image description here

enter image description here



لینک منبع

java – bufferedreader show same value when i deleted my text file from server


i work on a program that has to check if a text file content is changed on a server. i changed my .txt file but i always get same result. i deleted .txt file but its just the same…
here is my problem…

URL url1 = new URL(versionUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(url1.openStream()));
String str;

while ((str = in.readLine()) != null) {
    if (appver == Integer.parseInt(str))



لینک منبع

android two edit text in the middle of the screen


How can I layout the two edit txt fields in the middle of the screen.
Current layout is not align to middle of the screen.

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

        <EditText
            android:id="@+id/edit_code_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="0"
            android:inputType="number"
            android:maxLength="1"
            android:padding="10dp"
            android:textSize="20sp"
            />

        <EditText
            android:id="@+id/edit_code_2"
            android:layout_marginLeft="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="0"
            android:inputType="number"
            android:maxLength="1"
            android:padding="10dp"
            android:textSize="20sp" />
    </LinearLayout>



لینک منبع

python – How to replace text corpus using a matching word from dictionary using Regex


I am trying standardize my address data which present inside dataframe.

I was only able correctly replace words where in dictionary where one word has only one values. I am not noble to replace when one word has mutliple values .

Input data data[‘Postal_Addr’]

UNIT 3510 35/F THE CENTRE 99 QUEENS RD CENTRAL HONG KONG
HARNEYS THE CENTRE 99 QUEENS STR ROAD CETRAL
OCBC WING HANG BANK UNIT B 5/FLR WING HANG INSURANCE CENTRE BUILDING
M3 CAPITAL PARTNERS 50 CONNAUGHT RD. LEVEL 3 CENTRAL
GALERIE HONG KONG LDT 50 CONNAUGHT RD CENTRAL 17TH FLOOR HK
۳۶/FL INFINITUS PLAZA STREET SHEUNG
۵۱ SAI ST SHEUNG STRAT RAOD WAN HK

Dictionary

Mapping_matrix.set_index('Orginal')['Related_Words'].to_dict()

{'FLOOR ': 'F,FL,FLR',
 'ROAD': 'RD, RD.,RAOD',
 'STREET': 'ST, STR,STRAT'
 'CENTRAL': 'CENTRE, CETRAL'}

Expected Output

UNIT 3510 35/FLOOR THE CENTRAL 99 QUEENS ROAD CENTRAL HONG KONG
HARNEYS THE CENTRAL 99 QUEENS STREET ROAD CENTRAL
OCBC WING HANG BANK UNIT B 5/FLOOR WING HANG INSURANCE CENTRAL BUILDING
M3 CAPITAL PARTNERS 50 CONNAUGHT ROAD LEVEL 3 CENTRAL
GALERIE HONG KONG LDT 50 CONNAUGHT ROAD CENTRAL 17TH FLOOR HK
۳۶/FLOOR INFINITUS PLAZA STREET SHEUNG
۵۱ SAI STREET SHEUNG STREET ROAD WAN HK



لینک منبع

google chrome extension – Reading Text Files from Local Directory in Javascript


I’m working on a Chrome extension and I want to take data from text files that will be in the same directory as the Javascript files with the functionality (that is, read the text files in as strings and use those for analysis of some kind). I’m pretty new to Javascript, so I’ve been trying to figure out how to do this–it seems that FileReader won’t work since the user isn’t uploading the files I’m using, and I’m not sure how XML HTTPRequest would be useful in this situation. Thank you!

tldr; I want to read text files in the same directory as a Javascript file in as strings.



لینک منبع

Editing a text File in Java and saving it as a new text file


I have a text file with 5 lines, i wish to read in those lines and be able to number them 1 – 5, and save them in a different file. The numbers begin before the start of the line.I have tried to hard code in a loop to read in the number but i keep getting errors.

public class TemplateLab5Bronze {

 static final String INPUT_FILE = "testLab5Bronze.txt";
 static final String OUTPUT_FILE = "outputLab5Bronze.txt";

public static void main(String[] args) {
try {
  FileReader in =  new FileReader(INPUT_FILE);
  PrintWriter out = new PrintWriter(OUTPUT_FILE);
  System.out.println("Working");

  BufferedReader inFile = new BufferedReader(in);
  PrintWriter outFile = new PrintWriter(out);
  outFile.print("Does this print?n");


  String trial = "Tatot";
  outFile.println(trial);
  System.out.format("%d. This is the top linen", (int)1.);
  System.out.format("%d.                     n", (int)2.);
  System.out.format("%d. The previous one is blank.n", (int)3.);
  System.out.format("%d. Short onen", (int)4.);
  System.out.format("%d. This is the last one.n", (int)5.);
 /* if(int j = 1; j < 6; j++)
  {outFile.print( i + trial);} */

  String line;
  do{
    line = inFile.readLine();
    if(line != null){

    }

  }while(line !=null);
  inFile.close();

  in.close();
  outFile.close();
}

catch(IOException e){
  System.out.println("Doesnt Work");
}
System.out.print("Done stuff!");

}//main

This is all the code i have so far, excluding the import statements, the commented for loop is what i was trying to use. Is there another way to do this?



لینک منبع

jquery – Counting Specific text on a page


I have an html document that has a ‘status’ column. I need to count how many of these are marked Available or not Available.

I’ve tried to do something like this

$("td:contains(Available)" ).length;

but this is also picking up the “Not Available”‘s. Is there a way to only select the Available’s?

A example of the web page
http://www.cats-can.org/animals/list?Species=Cat



لینک منبع