public class DetailsCountry extends AppCompatActivity implements
TabLayout.OnTabSelectedListener,
EconomicFragment.EconomicOnFragmentInteractionListener,
SummarizeFragment.SummarizeOnFragmentInteractionListener,
HistoryFragment.HistoryOnFragmentInteractionListener,
GeographyFragment.GeographyOnFragmentInteractionListener,
TipsFragment.TipsOnFragmentInteractionListener,
DescriptionFragment.OtherOnFragmentInteractionListener,
PeopleFragment.PeopleOnFragmentInteractionListener {
public static String NAME_COUNTRY = "name";
public final String pageTitle[] = {"خلاصه",
"تاریخ",
"جغرافی",
"اقتصاد",
"مردم",
"غیره",
"نکات"};
ArrayList<AsiaCountry> asiaList = new ArrayList<>();
ImageView imageHistory;
TabLayout tabLayout;
ViewPager viewPager;
String content;
Bundle bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detial_country);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_details);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
viewPager = (ViewPager) findViewById(R.id.viewPager_detail_country);
tabLayout = (TabLayout) findViewById(R.id.tabLayout_detail_country);
imageHistory = (ImageView) findViewById(R.id.image_detail_country);
bundle = getIntent().getExtras();
if (bundle != null) {
content = bundle.getString("name");
Log.d("contentDetail", content);
}
// Set title for activity title.
getSupportActionBar().setTitle(content);
retrieveData();
if (asiaList != null && asiaList.size() > 0) {
for (int i = 0; i < asiaList.size(); i++) {
imageHistory.setImageBitmap(loadBitmapFromAssets(getApplicationContext(),
asiaList.get(i).getImageResourceID()));
}
}
int numberPage = 7;
for (int i = 0; i < numberPage; i++) {
tabLayout.addTab(tabLayout.newTab().setText(pageTitle[i]));
}
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
ViewPagerCountryAdapter viewPagerAdapter = new ViewPagerCountryAdapter
(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(viewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setOnTabSelectedListener(this);
}
private void retrieveData() {
WorldCountryDatabase worldCountryDatabase = new WorldCountryDatabase(getApplicationContext());
worldCountryDatabase.createDatabase();
worldCountryDatabase.openDataBase();
Log.d(ARG_PARAM1, "Database opened");
try {
Cursor cursor = worldCountryDatabase.QueryData("SELECT viewImage FROM country WHERE name = '" + content + "'");
Log.d("CURSOR", cursor.toString());
if (cursor.moveToFirst()) {
do {
AsiaCountry asia = new AsiaCountry();
asia.setImageResourceID(cursor.getString(0));
Log.d("image", cursor.getString(0));
asiaList.add(asia);
} while (cursor.moveToNext());
cursor.close();
}
} catch (SQLException e) {
e.printStackTrace();
Log.d("TAG", e.getMessage());
}
}
@Nullable
private Bitmap loadBitmapFromAssets(Context context, String path) {
InputStream stream = null;
try {
stream = context.getAssets().open(path);
return BitmapFactory.decodeStream(stream);
} catch (Exception ignored) {
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (Exception ignored) {
}
}
return null;
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(base));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
@Override
public void economiOnFragmentInteraction(Uri uri) {
}
@Override
public void tipsOnFragmentInteraction(Uri uri) {
}
@Override
public void otherOnFragmentInteraction(Uri uri) {
}
@Override
public void peopleOnFragmentInteraction(Uri uri) {
}
@Override
public void historyOnFragmentInteraction(Uri uri) {
}
@Override
public void geographyOnFragmentInteraction(Uri uri) {
}
@Override
public void summarizeOnFragmentInteraction(Uri uri) {
}
public class DetailTask extends AsyncTask<Void, Void, Boolean>{
@Override
protected Boolean doInBackground(Void... params) {
return null;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
}
}
这是我的代码。我搜索了有关变量列表的问题。他们的答案是用def matMinor3x3(mat,a,b):
minor=[[0,0],[0,0]]
temp1=mat[:]
for i in range(0,3):
del temp1[i][b-1]
del temp1[a-1]
return temp1
A=[[1,2,3],[4,5,6],[7,8,9]]
print A,matMinor3x3(A,1,1),A
制作副本。但是我很累,而且它不起作用。拆分列并重新组装它们以使复制也无效。请帮我。我正在制作逆矩阵码......