2011-09-09 5 views
0

자바와 Android로 내 이빨을 손가락으로 가리 켰습니다. Normaly는 Python으로 코드를 작성합니다. 쉽고 간단합니다!URL을 만들 수있는 형태의 Android noobie

자바 그래서 ... 나 또는 단지 내가 그래서 유일한 코드 작업은 복사 - 붙여 넣기하고 그것을 사용자 정의 할 어렵습니다 :(모를 유일한 방법은, 아무것도 할

을하자, 나는했습니다 결코 간단한 편집 가능한 텍스트와 버튼, 클릭하면 URL로 간다. 버튼이 작동한다 : 내 웹 뷰를 열 수있다. 하지만 editText로 URL을 만들고 싶지 않다. (

그래서

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

// Add Click listeners for all buttons 
    final EditText Login = (EditText) findViewById(R.id.entry); 
    View firstButton = findViewById(R.id.ok); 
    firstButton.setOnClickListener(this); 
} 

public void onClick(View v) { 

    switch(v.getId()){ 
     case R.id.ok: 
      Intent j = new Intent(this, Webscreen.class); 
      j.putExtra(com.tatai.froyo.Webscreen.URL, 
       "http://192.168.1.12/index2.php"); 
      startActivity(j); 
     break; 
    } 

, 어떻게 내가 할 수 있습니다

는 것을 알 다음과 같은 URL을 만들기 위해 로그인 edittext가 있습니다 http://192.168.1.12/index2.php?log=toto ... 여기서 toto는 login edittext로 얻을 수 있습니다.

onclick에서 글로벌 변수를 읽을 수 없습니다. 분실했습니다! . 는하지만 로그인 정보를 볼 수 없습니다, 그것은 밖으로이다; 문자열 logDetail = Login.getText의 toString()() : 코드에

+0

Login.getText를() 당신이 시작하는 것이다 toString()를 – Rob

+0

을 나는 물체가 내 두뇌없는 생각 ... 사람들이 너무 많이 다른 코드에 의해 고립되어 있으며 객체와 통신하기가 어렵습니다. 고유 한 중앙 집중식 선형 코드를 선호합니다! – Defcode

답변

0

선언되지 않은, :(

는 내가 온 클릭 리스너에 있음을 TRID! ,

public void onClick(View v) 
    {  
     switch(v.getId()) 
     {   
     case R.id.ok: 

      String logDetail = Login.getText().toString(); 

      Intent j = new Intent(this, Webscreen.class); 
      j.putExtra(com.tatai.froyo.Webscreen.URL,"http://192.168.1.12/index2.php?log="+logDetail); 
      startActivity(j);  
      break;  
      } 

편집이 시도 :..

EditText Login; 

public void onCreate(Bundle savedInstanceState) 
    {  
super.onCreate(savedInstanceState);  
setContentView(R.layout.main); 
// Add Click listeners for all buttons  

    Login = (EditText) findViewById(R.id.entry);  

View firstButton = findViewById(R.id.ok);  

    firstButton.setOnClickListener(this); 
    } 

    public void onClick(View v) 
    {  
     switch(v.getId()) 
     {   
     case R.id.ok: 

      String logDetail = Login.getText().toString(); 

      Intent j = new Intent(this, Webscreen.class); 

j.putExtra(com.tatai.froyo.Webscreen.URL,"http://192.168.1.12/index2.php?log="+logDetail); 
      startActivity(j);  
      break;  
      } 
+0

u'r 도움을 주셔서 감사합니다. 나는 그것을 시도했다. 그러나 그것은 말했다 : 로그인 undeclared – Defcode

+0

내 편집 된 대답을 봐. 이런 식으로 edittext를 선언해야 오류가 발생하지 않습니다. – user370305

+0

oh, editext 글로벌 var로 로그인? 나는 그것을 시도 할 것이다! – Defcode