我想创建一个使用互联网的应用程序,我正在尝试创建一个检查连接是否可用的功能,如果不可用,请转到具有重试按钮和解释的活动.
附件是我的代码到目前为止,但我收到了错误 Syntax error, insert "}" to complete MethodBody.
现在我一直把这些放在试图让它工作,但到目前为止没有运气...任何帮助将不胜感激.
public class TheEvoStikLeagueActivity extends Activity {
private final int SPLASH_DISPLAY_LENGHT = 3000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
private boolean checkInternetConnection() {
ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
// ARE WE CONNECTED TO THE NET
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
return true;
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after …
Run Code Online (Sandbox Code Playgroud) 如何在Android上创建Unix时间戳?
我想在url的末尾创建一个带有Unix时间戳的URL post请求.
嗨我有一个SwipeRefreshLayout,其中包含一个相对布局,其中包含滚动视图和另一个视图,当我向下滚动列表有时不会向上滚动而不是它运行onRefresh函数.除非视图位于顶部,否则如何阻止它运行?我读过有关canChildScrollUp但没有找到正确实现它的方法.
继承我的布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/profile"
android:background="@drawable/homepage_image_1">
<com.alldaypa.alldaypa.customviews.CircularImageView
android:layout_width="75dp"
android:layout_height="75dp"
app:border_color="#FFFFFF"
app:border_width="8dp"
app:shadow="false"
android:id="@+id/profile_image"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="70dp"
android:layout_marginTop="20dp"
android:src="@drawable/homepage_noimage_male"
android:clickable="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/profile_image"
android:layout_alignRight="@+id/profile_image"
android:src="@drawable/homepage_profile_add"
android:layout_marginRight="3dp"
android:layout_marginBottom="3dp"
/>
<TextView android:id="@+id/profile_name"
android:text="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_alignTop="@+id/profile_image"
android:layout_toRightOf="@+id/profile_image"
android:layout_marginTop="20dp"
android:textColor="@color/darkgrey"
android:layout_marginLeft="10dp"/>
<TextView android:id="@+id/company"
android:text="Company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_below="@+id/profile_name"
android:layout_alignLeft="@+id/profile_name"
android:textColor="@color/darkgrey"
android:layout_marginTop="-2dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/availability"
android:background="@color/white" …
Run Code Online (Sandbox Code Playgroud) 嗨,我正在制作一个检查互联网连接的应用程序,如果它没有连接,它会转到一个有错误消息的活动和一个我想链接到无线和网络设置的按钮.但我不知道怎么做,有人可以帮帮我吗?
这是我到目前为止所得到的.
public class NetworkActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.networkact);
Button settings = (Button) findViewById(R.id.btn_settings);
// Listening to button event
settings.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Starting a new Intent
Intent gotoSettings = new Intent(getApplicationContext(),
HomeActivity.class);
startActivity(gotoSettings);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
目前它进入另一项活动,但我希望它转到无线和网络设置.
嗨,我有一个问题,试图了解分段ListViews如何工作.我让它进入正常的列表视图.但现在我想在我的列表中添加部分.如何在中添加节标题.
继承我的代码是有效的.
public class ChooseTeamActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chooseact);
String FullData = getIntent().getStringExtra("FullData");
try{
JSONObject obj = new JSONObject(FullData);
List<String> leagues = new ArrayList<String>();
JSONObject objData = obj.getJSONObject("data");
JSONArray jArray = objData.getJSONArray("structure");
for (int i=0; i < jArray.length(); i++) {
JSONObject oneObject = jArray.getJSONObject(i);
leagues.add(oneObject.getString("league_website_name"));
JSONArray DivisionsArray = oneObject.getJSONArray("divisions");
for (int d=0; d < DivisionsArray.length(); d++){
JSONObject DivDict = DivisionsArray.getJSONObject(d);
leagues.add(DivDict.getString("name"));
}
}
setListAdapter ( new ArrayAdapter<String>(this, R.layout.single_item,
leagues));
ListView list = getListView(); …
Run Code Online (Sandbox Code Playgroud) 我想创建一个包含3个列表和3个标题的页面,但我不想单独滚动它们,我希望整个页面滚动.有谁知道我怎么能做到这一点?
基本上我希望它看起来像这样:
header
smlheader
list
smlheader
list
smlheader
list
Run Code Online (Sandbox Code Playgroud)
有了这段代码,我试图实现它,但它不是那么好.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<include layout="@layout/header" />
<include layout="@layout/redcell" />
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="60dp" >
<TextView
android:id="@+id/fixtures_text"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="@string/leagues"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"/>
</TableRow>
<include layout="@layout/redcell" />
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="60dp" >
<TextView
android:id="@+id/results_text"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:text="@string/leagues"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"/>
</TableRow>
<include layout="@layout/redcell" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</TableLayout>
<ScrollView/>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在创建我的第一个Android应用程序,我想知道什么是从URL解析JSON Feed的最佳和最有效的方法.也理想我想将它存储在某个地方所以我可以继续回到它在应用程序的不同部分.我到处寻找,发现了许多不同的方法,我不知道该去哪.在您看来,有效且轻松地解析json的最佳方法是什么?