Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio


AD MOB

Try this code:

final String ERROR = "my error message....";

 private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
// some code and method ..... see AsyncTask

       @Override
        protected String doInBackground(String... urls) {

              URL urlL = null;
                try {
                    urlL = new URL(url);//"//chmi.cz..../"
                    HttpURLConnection urlConnection = null;
                    try {
                         urlConnection = (HttpURLConnection) urlL.openConnection();
                        InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                      response =  readStream(in);
                        return response;
                    } catch (IOException e) {
                        //throw new RuntimeException(e);

                    } finally {
                        if(urlConnection != null)
                            urlConnection.disconnect();
                        return ERROR;
                    }
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    return ERROR;
                }
           }
            return response;
        }

        private String readStream(InputStream is) {
            try {
                ByteArrayOutputStream bo = new ByteArrayOutputStream();
                int i = is.read();
                while(i != -1) {
                    bo.write(i);
                    i = is.read();
                }
                return bo.toString();
            } catch (IOException e) {
                return "";
            }
        }


397LW NO topic_id




AD

Další témata ....(Topics)


278

Change Screen Orientation Programmatically Android | change-screen-orientation-programmatically-android


Landscape - portrait orientation change:

boolean mbOrientationLandscape = true;
if(mbOrientationLandscape ){
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	mbOrientationLandscape =false;
}else{
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
	mbOrientationLandscape =true;
}

99

Essential Eclipse Shortcuts with pictures | essential-eclipse-shortcuts-with-pictures


Eclipse Navigation Shortcuts.

Keyboard_shortcuts_(3.0).pdf
Ctrl+1 Quick fix problem
eclipse-ctrl-1



Ctrl+O Quick Outline
eclipse-ctrl-o



Ctrl+Shift+G Find references in workspace
Ctrl+Shift+U Find all references in file
eclipse-ctrl-shift-u




Ctrl+Shift+T Find Java Typ

[caption id="attachment_1214" align="alignleft" width="150" caption="eclipse-ctrl-shift-t"][/caption]


Ctrl+Shift+R Find Resource



Ctrl+E Open Editor Drop-Down
Ctrl+Space Content Assist
eclipse-ctrl-space


Ctrl+Shift+Space Context Information

eclipse-ctrl-shift-space


F3 Open Declaration of variable
F4 Open Type Hierarchy
Ctrl+H Open Search Dialog
Alt+Shift+R Rename - Refactoring
Alt+Shift+M Extract Method
Alt+Shift+L Extract Local Variable

Alt Shift Up Expand selection to enclosing element
Alt Shift Right Expand selection to next element
Alt Shift Left Expand selection to previous element
Alt Shift Down Restore previous selection

Breakpoints Shift+Alt+Q B
Cheat Sheets Shift+Alt+Q H
Console Shift+Alt+Q C
Java Declaration Shift+Alt+Q D
Java Package Explorer Shift+Alt+Q P
Java Type Hierarchy Shift+Alt+Q T
Javadoc Shift+Alt+Q J
Search Shift+Alt+Q S
Show View (View: Outline)Shift+Alt+Q O
Show View (View: Problems)Shift+Alt+Q X
Synchronize Shift+Alt+Q Y
Variables Shift+Alt+Q V

271

How to add or remove widgets home screen android 4 | how-to-add-or-remove-widgets-home-screen-android-4


Video tutorial
How to add or remove widgets home screen Android 4.


33

Spinner ComboBox DropDown List Android example code | spinner-combobox-dropdown-list-android-code-example


Spinner in Android application is equivalent of ComboBox in WinApi.
Spinner get selected item to string example.
Spinner get selected item position to int example.

Main activity class MainComboBox.java

public class MainComboBox extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Spinner spinner = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.countries_array, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

        Button myButton =(Button)findViewById(R.id.button1);
        myButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
            	
            Spinner sp =	(Spinner)findViewById(R.id.spinner);
            String spinnerString = null;
            spinnerString = sp.getSelectedItem().toString();
            int nPos = sp.getSelectedItemPosition();
            
             
                Toast.makeText(getApplicationContext(), "getSelectedItem=" + spinnerString,
                    Toast.LENGTH_LONG).show();
                Toast.makeText(getApplicationContext(), "getSelectedItemPosition=" + nPos,
                		Toast.LENGTH_LONG).show();
            }
        });
    }
}



File MyOnItemSelectedListener.java

public  class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) {
      Toast.makeText(parent.getContext(), "Item is " +
          parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
    }

    public void onNothingSelected(AdapterView parent) {
      // Do nothing.
    }
}


strings.xml

<resources>
    <string name="hello">Hello World, MainComboBox!</string>
    <string name="app_name">ComboBox</string>
    <string name="prompt">Choose a country</string>
    <string-array name="countries_array">
        <item>China</item>
        <item>India</item>
        <item>USA</item>
        <item>Indonesia</item>
        <item>Brazil</item>
        <item>Pakistan</item>
        <item>Nigeria</item>
        <item>Bangladesh</item>
        <item>Russia</item>
    </string-array>    
</resources>


main.xml

<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="@string/prompt"
    />
    <Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:prompt="@string/prompt"
    />
    <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>




19

How set focus on View Android development example | how-set-focus-on-view-android-development-example


Set focus on a View in Android application example source code for Button, EditText, View, TextView, isFocused(), requestFocus() .


// set focus on Button Android example
 private Button mRightButton;
 mRightButton = (Button) a.findViewById(R.id.rightButton);
 mRightButton.requestFocus();
// boolean isFocused() 
boolean b = mRightButton.isFocused(); // true or false

// set focus on TextView directly Android example
((TextView) findViewById(R.id.myText)).requestFocus();

// set focus on View Android example
private View mView;
mView = findViewById(R.id.showAll);
mView.requestFocus();

// set focus on EditText Android example
private EditText mEdit;
mEdit = (EditText)findViewById(R.id.myEdit);
mEdit.requestFocus();


Editace: 2015-12-10 19:13:01
Počet článků v kategorii: 397
Url:cannot-resolve-symbol-httpgethttpclienthttpresponce-in-android-studio

AD
11 Share
Share
Tweet